pythondjangobackenddjango-1.6

Custom django admin template for app


I would like to create a custom index.html derived from the admin/index.html individual for each app in my django project.

For instance my folder structure is like:

How can I achieve custom admin index.html files for my apps, that are recognized by django? For the moment only the index.html in the global template/admin folder is considered for rendering the index pages in my backend.

I'm using django 1.6


Solution

  • Unfortunately, only certain parts of the Django admin site can be overridden on a per-app basis, as it says in the documentation:

    Not every template in contrib/admin/templates/admin may be overridden per app or per model. The following can:

    • app_index.html
    • change_form.html
    • change_list.html
    • delete_confirmation.html
    • object_history.html

    Remember that the admin interface is itself and app, so it's going to do a single template sweep and load the first set of templates that comes up.

    I think your two best bets are either to use multiple admin sites in your project or to add a custom view for specific apps -- the former is probably easier, but will be a problem if you don't want people to have to login separately to control certain things.