[Django] #16915: contrib.admin should use a variable to select base_site template

4 views
Skip to first unread message

Django

unread,
Sep 22, 2011, 1:13:14 PM9/22/11
to django-...@googlegroups.com
#16915: contrib.admin should use a variable to select base_site template
-------------------------+-------------------------------
Reporter: CBWhiz | Owner: nobody
Type: New feature | Status: new
Milestone: | Component: contrib.admin
Version: 1.3 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------+-------------------------------
Currently, I have two AdminSite instances. I'd like them to be customized
in different ways. For this example, suppose I want a different branding
for each section (say 'Warehouse Admin' and 'Content Admin') at the top of
every admin page.

The current suggested way to customize the admin is to create a new
`admin/base_site.html` file and fill in the `branding` and `title` blocks.
However, in the scenario above, both AdminSite instances will use the same
base_site template.

I suggest AdminSite be given a new instance level attribute called
`base_template_name`, have all admin views pass this variable to the
template context (or create an admin ContextProcessor), and change each
admin template from `{% extends "admin/base_site.html" %}` to `{% extends
admin_base %}`.

Another option would be just changing the subdirectory of the include
(that is, allow each AdminSite to change the '/admin' default).

I suspect this may be able to be solved externally from the AdminSite and
templates with a customized TemplateLoader, but i'm not sure how to best
indicate that a particular TemplateLoader be used for a particular view
response, as that seems to be a global list in the settings module.

--
Ticket URL: <https://code.djangoproject.com/ticket/16915>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 22, 2011, 1:17:37 PM9/22/11
to django-...@googlegroups.com
#16915: contrib.admin should use a variable to select base_site template
---------------------------------------+-------------------------------
Reporter: CBWhiz | Owner: nobody
Type: New feature | Status: new
Milestone: | Component: contrib.admin
Version: SVN | Severity: Normal
Resolution: | Keywords:
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------+-------------------------------
Changes (by carljm):

* needs_better_patch: => 0
* version: 1.3 => SVN
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted


Comment:

I lean towards being able to set the template base directory
per-`AdminSite`, rather than pointing to the base template itself, as that
gives even more flexibility if you want to e.g. just customize the change
page for a single model, per-`AdminSite`. In any case, this is a valid use
case that ought to be made easier.

--
Ticket URL: <https://code.djangoproject.com/ticket/16915#comment:1>

Django

unread,
Sep 27, 2011, 1:12:56 PM9/27/11
to django-...@googlegroups.com
#16915: contrib.admin should use a variable to select base_site template
---------------------------------------+-------------------------------
Reporter: CBWhiz | Owner: nobody
Type: New feature | Status: new
Milestone: | Component: contrib.admin
Version: SVN | Severity: Normal
Resolution: | Keywords:
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------+-------------------------------

Comment (by CBWhiz):

As a temporary workaround, this Middleware and TemplateLoader does the
job: https://gist.github.com/1245626.

Note that this uses the threadlocal hack everyone seems to hate. Also note
that if you're using Coffin for Jinja2 support, that will break due to
https://github.com/coffin/coffin/issues/23 until you apply a workaround
like that described in https://github.com/coffin/coffin/pull/24

--
Ticket URL: <https://code.djangoproject.com/ticket/16915#comment:2>

Django

unread,
Oct 31, 2025, 10:24:44 AM10/31/25
to django-...@googlegroups.com
#16915: contrib.admin should use a variable to select base_site template
-------------------------------+------------------------------------
Reporter: CBWhiz | Owner: nobody
Type: New feature | Status: closed
Component: contrib.admin | Version: dev
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Alexandre Petitjean):

* resolution: => fixed
* status: new => closed

Comment:

Feature added in
https://github.com/django/django/commit/a962286b74f1e8c8cb19fb45a057800da8c2fb56
--
Ticket URL: <https://code.djangoproject.com/ticket/16915#comment:3>
Reply all
Reply to author
Forward
0 new messages