Search code examples
pythondjangodjango-adminadminextend

How can I extend Django Admin by adding values above the list of model entries?


I just started to use Django Admin. I have my code that tells Django Admin to show all entries in /admin/ page from my model.

I would like to extend the list by adding values above it. I want to display total number of entries that match criteria #1 and total entries that match criteria #2. I don't want to change the list tho. That content is independent.

To get that content, I need to do two queries. This means that I shouldn't do it in the template and I shouldn't just pass the name of template to the attribute change_list_template.

The next thing I though was to extend chnagelist_view, but capture the response and add my values to it. The only problem is that I think there is a better way; there got to be a better way!


Solution

  • After research the tricks were to:

    1. Overriding admin templates,
    2. Passing variables to the template,