Skip to content Skip to sidebar Skip to footer

How To Get An Associated Model Via A Custom Admin Action In Django?

Part 2 of this question asked and answered separately. I have a Report and a ReportTemplate. +----+----------+---------------+-------------+ | id | title | data | temp

Solution 1:

Just get the template field of your Report model:

defprint_as_pdf(self, request, queryset):
    for report inqueryset:
        markup = report.template.markup
        ...
print_as_pdf.short_description = 'Generate as pdf'

UPDATE: To use the logger you should add these two lines at the beginning of the source file:

importlogginglogger= logging.getLogger(__name__)

Post a Comment for "How To Get An Associated Model Via A Custom Admin Action In Django?"