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.
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>
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>
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>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/32681#comment:4>
* 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>
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/32681#comment:6>
* needs_docs: 1 => 0
* needs_tests: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/32681#comment:7>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/32681#comment:8>
* 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>
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>
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>
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>
* cc: Jon Dufresne (removed)
--
Ticket URL: <https://code.djangoproject.com/ticket/32681#comment:13>
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>