Opened 15 months ago

Closed 15 months ago

Last modified 15 months 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 Changed 15 months ago 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?

comment:2 Changed 15 months ago 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.

comment:3 Changed 15 months ago by Carlton Gibson

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 15 months ago by Carlton Gibson (previous) (diff)

comment:4 Changed 15 months ago by Carlton Gibson

Has patch: set
Last edited 15 months ago by Mariusz Felisiak (previous) (diff)

comment:5 Changed 15 months ago by Mariusz Felisiak

Triage Stage: AcceptedReady for checkin

comment:6 Changed 15 months ago by Carlton Gibson <carlton@…>

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 Changed 15 months ago by Carlton Gibson <carlton.gibson@…>

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