[Django] #31865: Missing variable in admin template

143 views
Skip to first unread message

Django

unread,
Aug 7, 2020, 3:30:28 AM8/7/20
to django-...@googlegroups.com
#31865: Missing variable in admin template
---------------------------------------------+------------------------
Reporter: Christian Ullrich | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 3.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------------+------------------------
The `admin/nav_sidebar.html` template appears to be missing an assignment
to `show_changelinks` where it includes `app_list.html`:

{{{
{% include 'admin/app_list.html' with app_list=available_apps %}
}}}

This leads to megabytes of log spam for every admin page visited with the
sidebar on:

{{{
2020-08-07 09:06:49,882 [DEBUG ] (django.template) Exception while
resolving variable 'show_changelinks' in template
'admin/change_list.html'.
Traceback (most recent call last):
File "[python]\lib\site-packages\django\template\base.py", line 829, in
_resolve_lookup
current = current[bit]
File "[python]\lib\site-packages\django\template\context.py", line 83,
in __getitem__
raise KeyError(key)
KeyError: 'show_changelinks'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "[python]\lib\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
'show_changelinks'

During handling of the above exception, another exception occurred:

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

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "[python]\lib\site-packages\django\template\base.py", line 848, in
_resolve_lookup
raise VariableDoesNotExist("Failed lookup for key "
django.template.base.VariableDoesNotExist: Failed lookup for key
[show_changelinks] in [{'True': True, 'False': False, 'None': None},}}}

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

Django

unread,
Aug 7, 2020, 4:07:24 AM8/7/20
to django-...@googlegroups.com
#31865: Missing variable in admin template
-----------------------------------+--------------------------------------

Reporter: Christian Ullrich | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 3.1
Severity: Normal | Resolution:

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

Comment (by Carlton Gibson):

Hi.

First pass, I'd say this is deliberately leveraging the DTL's behaviour of
allowing context variables to be undefined. I wouldn't be logging these:
`django.template.base.VariableDoesNotExist`, they're expected.

So, again first pass, do you really want your logging turned up that high?

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

Django

unread,
Aug 7, 2020, 3:19:59 PM8/7/20
to django-...@googlegroups.com
#31865: Missing variable in admin template
-----------------------------------+--------------------------------------

Reporter: Christian Ullrich | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 3.1
Severity: Normal | Resolution:

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

Comment (by Tim Graham):

The logging comes from dc5b01ad05e50ccde688c73c2ed3334a956076b0 (if DEBUG
is True).

I haven't looked into the details but I'd suggest accepting this issue.

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

Django

unread,
Aug 11, 2020, 2:39:17 AM8/11/20
to django-...@googlegroups.com
#31865: Missing variable in admin template
-------------------------------------+-------------------------------------
Reporter: Christian Ullrich | Owner: Carlton
| Gibson
Type: Bug | Status: assigned
Component: contrib.admin | Version: 3.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* owner: nobody => Carlton Gibson
* status: new => assigned
* severity: Normal => Release blocker
* easy: 0 => 1
* stage: Unreviewed => Accepted


Comment:

OK, thanks Tim. I still have to set `level=DEBUG` on the `django.template`
logger (or a parent) to see this but it's a simple adjustment to quieten
that down.
PR shortly.

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

Django

unread,
Aug 11, 2020, 4:15:23 AM8/11/20
to django-...@googlegroups.com
#31865: Missing variable in admin template
-------------------------------------+-------------------------------------
Reporter: Christian Ullrich | Owner: Carlton
| Gibson
Type: Bug | Status: assigned
Component: contrib.admin | Version: 3.1

Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* has_patch: 0 => 1


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

Django

unread,
Aug 11, 2020, 4:29:25 AM8/11/20
to django-...@googlegroups.com
#31865: Missing variable in admin template
-------------------------------------+-------------------------------------
Reporter: Christian Ullrich | Owner: Carlton
| Gibson
Type: Bug | Status: assigned
Component: contrib.admin | Version: 3.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

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

* stage: Accepted => Ready for checkin


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

Django

unread,
Aug 11, 2020, 5:42:51 AM8/11/20
to django-...@googlegroups.com
#31865: Missing variable in admin template
-------------------------------------+-------------------------------------
Reporter: Christian Ullrich | Owner: Carlton
| Gibson
Type: Bug | Status: closed
Component: contrib.admin | Version: 3.1
Severity: Release blocker | Resolution: fixed

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

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson <carlton@…>):

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


Comment:

In [changeset:"0aeb802cf054cb369646c871b53c93a83c1fa58a" 0aeb802c]:
{{{
#!CommitTicketReference repository=""
revision="0aeb802cf054cb369646c871b53c93a83c1fa58a"
Fixed #31865 -- Adjusted admin nav sidebar template to reduce debug
logging.

Thanks to Mariusz Felisiak for review.
}}}

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

Django

unread,
Aug 11, 2020, 5:44:12 AM8/11/20
to django-...@googlegroups.com
#31865: Missing variable in admin template
-------------------------------------+-------------------------------------
Reporter: Christian Ullrich | Owner: Carlton
| Gibson
Type: Bug | Status: closed
Component: contrib.admin | Version: 3.1

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

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

Comment (by Carlton Gibson <carlton.gibson@…>):

In [changeset:"02b474f2a4675bffee0cc1396a9c4ad22aef3580" 02b474f]:
{{{
#!CommitTicketReference repository=""
revision="02b474f2a4675bffee0cc1396a9c4ad22aef3580"
[3.1.x] Fixed #31865 -- Adjusted admin nav sidebar template to reduce
debug logging.

Thanks to Mariusz Felisiak for review.

Backport of 0aeb802cf054cb369646c871b53c93a83c1fa58a from master
}}}

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

Reply all
Reply to author
Forward
0 new messages