#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 , 4 years ago
comment:2 by , 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 , 4 years ago
Easy pickings: | set |
---|---|
Owner: | changed from | to
Severity: | Normal → Release blocker |
Status: | new → assigned |
Triage Stage: | Unreviewed → Accepted |
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.
comment:5 by , 4 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
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?