python - Export django model as pdf from admin model -
i export model pdf file directly model admin using reportlab.
class invoiceitem(models.model): invoice_number = models.charfield(max_length=50) invoice_date = models.datefield('invoice date') invoice_sent = models.booleanfield() invoice_paid = models.booleanfield()
and model admin:
class invoiceitemadmin(admin.modeladmin): def pdf_version(self, obj): ## how call reportlab view here ??
please help, m.
use actions! i'm taking created reportlab view , want redirect model items. create function (outside of class):
def pdf_version(modeladmin, request, queryset): url = '/your_pdf_url/?pks=' + ','.join([q.pk q in queryset]) httpresponseredirect(url)
then in admin:
class invoiceitemadmin(admin.modeladmin): actions = [pdf_version]
in example using data allow more 1 report @ time, because seems reasonable, can change you'd like. it's easy that. check out documentation futher details
Comments
Post a Comment