[Django] #32681: 'subtitle' missing from admin context on index page

546 views
Skip to first unread message

Django

unread,
Apr 23, 2021, 8:31:29 PM4/23/21
to django-...@googlegroups.com
#32681: 'subtitle' missing from admin context on index page
-----------------------------------------+---------------------------------
Reporter: Zain Patel | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 3.2
Severity: Normal | Keywords: admin, template
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+---------------------------------
This looks like a bug introduced in Django 3.2 with the introduction of a
new variable introduced in the base templates
(`django/contrib/admin/templates/base_site.html`) named `subtitle.` This
variable is passed in most places within the admin site, e.g in
django/contrib/admin/options.py

Loading the admin index page with log-level debug shows the following
exception/stack trace (that admittedly does not affect anything functional
- simply clutters the logs):


{{{
Exception while resolving variable 'subtitle' in template
'admin/index.html'.
Traceback (most recent call last):
File "...lib/python3.7/site-packages/django/template/base.py", line 829,
in _resolve_lookup
current = current[bit]
File "...lib/python3.7/site-packages/django/template/context.py", line
83, in __getitem__
raise KeyError(key)
KeyError: 'subtitle'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "...lib/python3.7/site-packages/django/template/base.py", line 835,
in _resolve_lookup
if isinstance(current, BaseContext) and getattr(type(current), bit):
AttributeError: type object 'RequestContext' has no attribute 'subtitle'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "...lib/python3.7/site-packages/django/template/base.py", line 843,
in _resolve_lookup
current = current[int(bit)]
ValueError: invalid literal for int() with base 10: 'subtitle'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "...lib/python3.7/site-packages/django/template/base.py", line 850,
in _resolve_lookup
(bit, current)) # missing attribute
django.template.base.VariableDoesNotExist: Failed lookup for key
[subtitle] in
}}}

I believe this can be fixed by providing `subtitle: None` in the
AdminSite.each_context` method to default it to that. I am happy to create
a PR for this.

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

Django

unread,
Apr 23, 2021, 8:35:03 PM4/23/21
to django-...@googlegroups.com
#32681: 'subtitle' missing from admin context on index page
---------------------------------+--------------------------------------

Reporter: Zain Patel | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 3.2
Severity: Normal | Resolution:

Keywords: admin, template | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Description changed by Zain Patel:

Old description:

New description:

On second though - instead of hardcoding `subtitle` to None - potentially
it should be a customisable option in the AdminSite itself, so:

class MySite(AdminSite):
site_header = "blah"
subtitle = "my subtitle"

?

--

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

Django

unread,
Apr 23, 2021, 8:35:23 PM4/23/21
to django-...@googlegroups.com
#32681: 'subtitle' missing from admin context on index page
---------------------------------+--------------------------------------

Reporter: Zain Patel | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 3.2
Severity: Normal | Resolution:

Keywords: admin, template | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Description changed by Zain Patel:

Old description:

> This looks like a bug introduced in Django 3.2 with the introduction of a

> On second though - instead of hardcoding `subtitle` to None - potentially
> it should be a customisable option in the AdminSite itself, so:
>
> class MySite(AdminSite):
> site_header = "blah"
> subtitle = "my subtitle"
>
> ?

New description:

On second though - instead of hardcoding `subtitle` to None - potentially


it should be a customisable option in the AdminSite itself, so:

{{{
class MySite(AdminSite):
site_header = "blah"
subtitle = "my subtitle"
}}}

?

--

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

Django

unread,
Apr 23, 2021, 8:55:56 PM4/23/21
to django-...@googlegroups.com
#32681: 'subtitle' missing from admin context on index page
---------------------------------+--------------------------------------

Reporter: Zain Patel | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 3.2
Severity: Normal | Resolution:

Keywords: admin, template | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by Zain Patel):

Potential fix as described in my ticket here:
https://github.com/django/django/pull/14308

--
Ticket URL: <https://code.djangoproject.com/ticket/32681#comment:3>

Django

unread,
Apr 23, 2021, 9:09:51 PM4/23/21
to django-...@googlegroups.com
#32681: 'subtitle' missing from admin context on index page
---------------------------------+--------------------------------------

Reporter: Zain Patel | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 3.2
Severity: Normal | Resolution:

Keywords: admin, template | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Zain Patel):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/32681#comment:4>

Django

unread,
Apr 24, 2021, 11:46:03 AM4/24/21
to django-...@googlegroups.com
#32681: Variable lookup errors are logged rendering the admin index page if
subtitle is not defined.
---------------------------------+--------------------------------------
Reporter: Zain Patel | Owner: Zain Patel
Type: Bug | Status: assigned
Component: contrib.admin | Version: 3.2
Severity: Release blocker | Resolution:

Keywords: admin, template | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => assigned
* severity: Normal => Release blocker
* cc: Jon Dufresne (added)
* needs_tests: 0 => 1
* owner: nobody => Zain Patel
* needs_docs: 0 => 1


Comment:

Thanks for the report.

Regression in 84609b3205905097d7d3038d32e6101f012c0619.

--
Ticket URL: <https://code.djangoproject.com/ticket/32681#comment:5>

Django

unread,
Apr 24, 2021, 11:46:13 AM4/24/21
to django-...@googlegroups.com
#32681: Variable lookup errors are logged rendering the admin index page if
subtitle is not defined.
---------------------------------+--------------------------------------
Reporter: Zain Patel | Owner: Zain Patel
Type: Bug | Status: assigned
Component: contrib.admin | Version: 3.2
Severity: Release blocker | Resolution:
Keywords: admin, template | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/32681#comment:6>

Django

unread,
Apr 24, 2021, 1:17:24 PM4/24/21
to django-...@googlegroups.com
#32681: Variable lookup errors are logged rendering the admin index page if
subtitle is not defined.
---------------------------------+--------------------------------------
Reporter: Zain Patel | Owner: Zain Patel
Type: Bug | Status: assigned
Component: contrib.admin | Version: 3.2
Severity: Release blocker | Resolution:
Keywords: admin, template | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Zain Patel):

* needs_docs: 1 => 0
* needs_tests: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/32681#comment:7>

Django

unread,
Apr 26, 2021, 1:09:29 AM4/26/21
to django-...@googlegroups.com
#32681: Variable lookup errors are logged rendering the admin index page if
subtitle is not defined.
-------------------------------------+-------------------------------------

Reporter: Zain Patel | Owner: Zain
| Patel
Type: Bug | Status: assigned
Component: contrib.admin | Version: 3.2
Severity: Release blocker | Resolution:
Keywords: admin, template | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/32681#comment:8>

Django

unread,
Apr 26, 2021, 6:48:10 AM4/26/21
to django-...@googlegroups.com
#32681: Variable lookup errors are logged rendering the admin index page if
subtitle is not defined.
-------------------------------------+-------------------------------------
Reporter: Zain Patel | Owner: Zain
| Patel
Type: Bug | Status: closed
Component: contrib.admin | Version: 3.2
Severity: Release blocker | Resolution: fixed

Keywords: admin, template | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

In [changeset:"4e5bbb6ef2287126badd32842b239f4a8a7394ca" 4e5bbb6e]:
{{{
#!CommitTicketReference repository=""
revision="4e5bbb6ef2287126badd32842b239f4a8a7394ca"
Fixed #32681 -- Fixed VariableDoesNotExist when rendering some admin
template.

Regression in 84609b3205905097d7d3038d32e6101f012c0619.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32681#comment:9>

Django

unread,
Apr 26, 2021, 6:53:10 AM4/26/21
to django-...@googlegroups.com
#32681: Variable lookup errors are logged rendering the admin index page if
subtitle is not defined.
-------------------------------------+-------------------------------------
Reporter: Zain Patel | Owner: Zain
| Patel
Type: Bug | Status: closed
Component: contrib.admin | Version: 3.2

Severity: Release blocker | Resolution: fixed
Keywords: admin, template | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"0dfe88eaba551ab3ecec9a573d59e8d2fa3a8f94" 0dfe88e]:
{{{
#!CommitTicketReference repository=""
revision="0dfe88eaba551ab3ecec9a573d59e8d2fa3a8f94"
[3.2.x] Fixed #32681 -- Fixed VariableDoesNotExist when rendering some
admin template.

Regression in 84609b3205905097d7d3038d32e6101f012c0619.

Backport of 4e5bbb6ef2287126badd32842b239f4a8a7394ca from main.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32681#comment:10>

Django

unread,
Jan 12, 2022, 3:57:17 AM1/12/22
to django-...@googlegroups.com
#32681: Variable lookup errors are logged rendering the admin index page if
subtitle is not defined.
-------------------------------------+-------------------------------------
Reporter: Zain Patel | Owner: Zain
| Patel
Type: Bug | Status: closed
Component: contrib.admin | Version: 3.2

Severity: Release blocker | Resolution: fixed
Keywords: admin, template | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Sourav Kumar):

I'm still facing this same issue even after updating to the Django 3.2.9.

Replying to [ticket:32681 Zain Patel]:

> On second though - instead of hardcoding `subtitle` to None -
potentially it should be a customisable option in the AdminSite itself,
so:
>
> {{{
> class MySite(AdminSite):
> site_header = "blah"
> subtitle = "my subtitle"
> }}}
>
> ?

--
Ticket URL: <https://code.djangoproject.com/ticket/32681#comment:11>

Django

unread,
Jan 12, 2022, 5:24:59 AM1/12/22
to django-...@googlegroups.com
#32681: Variable lookup errors are logged rendering the admin index page if
subtitle is not defined.
-------------------------------------+-------------------------------------
Reporter: Zain Patel | Owner: Zain
| Patel
Type: Bug | Status: closed
Component: contrib.admin | Version: 3.2

Severity: Release blocker | Resolution: fixed
Keywords: admin, template | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

Replying to [comment:11 Sourav Kumar]:


> I'm still facing this same issue even after updating to the Django
3.2.9.

Thanks for the report. I prepared
[https://github.com/django/django/pull/15308 PR] with follow up. Does it
work for you?

--
Ticket URL: <https://code.djangoproject.com/ticket/32681#comment:12>

Django

unread,
Jan 12, 2022, 9:03:12 AM1/12/22
to django-...@googlegroups.com
#32681: Variable lookup errors are logged rendering the admin index page if
subtitle is not defined.
-------------------------------------+-------------------------------------
Reporter: Zain Patel | Owner: Zain
| Patel
Type: Bug | Status: closed
Component: contrib.admin | Version: 3.2

Severity: Release blocker | Resolution: fixed
Keywords: admin, template | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jon Dufresne):

* cc: Jon Dufresne (removed)


--
Ticket URL: <https://code.djangoproject.com/ticket/32681#comment:13>

Django

unread,
Jan 13, 2022, 4:10:58 AM1/13/22
to django-...@googlegroups.com
#32681: Variable lookup errors are logged rendering the admin index page if
subtitle is not defined.
-------------------------------------+-------------------------------------
Reporter: Zain Patel | Owner: Zain
| Patel
Type: Bug | Status: closed
Component: contrib.admin | Version: 3.2

Severity: Release blocker | Resolution: fixed
Keywords: admin, template | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by GitHub <noreply@…>):

In [changeset:"0a4a5e5bacc354df3132d0fcf706839c21afb89d" 0a4a5e5]:
{{{
#!CommitTicketReference repository=""
revision="0a4a5e5bacc354df3132d0fcf706839c21afb89d"
Refs #32681 -- Fixed VariableDoesNotExist when rendering some admin
template.

Regression in 84609b3205905097d7d3038d32e6101f012c0619.

Follow up to 4e5bbb6ef2287126badd32842b239f4a8a7394ca.

Thanks Sourav Kumar for the report.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32681#comment:14>

Reply all
Reply to author
Forward
0 new messages