Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#31865 closed Bug (fixed)

Missing variable in admin template

Reported by: Christian Ullrich Owned by: Carlton Gibson
Component: contrib.admin Version: 3.1
Severity: Release blocker Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

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},}}}

Change History (7)

comment:1 by Carlton Gibson, 4 years ago

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?

comment:2 by Tim Graham, 4 years ago

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

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

comment:3 by Carlton Gibson, 4 years ago

Easy pickings: set
Owner: changed from nobody to Carlton Gibson
Severity: NormalRelease blocker
Status: newassigned
Triage Stage: UnreviewedAccepted

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.

Last edited 4 years ago by Carlton Gibson (previous) (diff)

comment:4 by Carlton Gibson, 4 years ago

Has patch: set
Last edited 4 years ago by Mariusz Felisiak (previous) (diff)

comment:5 by Mariusz Felisiak, 4 years ago

Triage Stage: AcceptedReady for checkin

comment:6 by Carlton Gibson <carlton@…>, 4 years ago

Resolution: fixed
Status: assignedclosed

In 0aeb802c:

Fixed #31865 -- Adjusted admin nav sidebar template to reduce debug logging.

Thanks to Mariusz Felisiak for review.

comment:7 by Carlton Gibson <carlton.gibson@…>, 4 years ago

In 02b474f:

[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

Note: See TracTickets for help on using tickets.
Back to Top