Opened 7 years ago

Closed 7 years ago

#28516 closed Cleanup/optimization (duplicate)

Admin change_list logs multiple "VariableDoesNotExist" errors.

Reported by: Samuel Bishop Owned by: nobody
Component: contrib.admin Version: 1.11
Severity: Normal Keywords: VariableDoesNotExist, django.contrib.admin, admin, template, logging, errors,
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Samuel Bishop)

By default the Django admin list view logs multiple errors while working normally. This is somewhat undesirable since errors and tracebacks do not typically accompany correct and expected behaviour.

Simply silencing all 'debug' template errors is less than ideal since it hides other possible errors we want to be informed about.
If the error were shorter, perhaps not including the traceback, that may be enough to improve the situation.
Basically, I don't expect the well tested and maintained admin templates to emit a wall of errors that is more reminiscent of the entire world being on fire due to horribly buggy code I have written.

This is the same issue that is behind #26886, just in a different template. If there is no way to solve these at the template code level, its probably fair to close this ticket as a duplicate of a new ticket for the underlying problem that needs solving to make this less of an issue.

This is the large amount of error text accompanying debug logging when loading any admin list view. This is all produced by a single page load of admin list for a sample model.

2017-08-22T03:04:44.811998Z [debug    ] Exception while resolving variable 'errors' in template 'admin/change_list.html'. [django.template] 
Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 885, in _resolve_lookup
    current = current[bit]
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 893, in _resolve_lookup
    current = getattr(current, bit)
AttributeError: 'NoneType' object has no attribute 'errors'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 900, in _resolve_lookup
    current = current[int(bit)]
ValueError: invalid literal for int() with base 10: 'errors'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 907, in _resolve_lookup
    (bit, current))  # missing attribute
django.template.base.VariableDoesNotExist: Failed lookup for key [errors] in 'None'
2017-08-22T03:04:44.816519Z [debug    ] Exception while resolving variable 'errors' in template 'admin/change_list.html'. [django.template] 
Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 885, in _resolve_lookup
    current = current[bit]
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 893, in _resolve_lookup
    current = getattr(current, bit)
AttributeError: 'NoneType' object has no attribute 'errors'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 900, in _resolve_lookup
    current = current[int(bit)]
ValueError: invalid literal for int() with base 10: 'errors'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 907, in _resolve_lookup
    (bit, current))  # missing attribute
django.template.base.VariableDoesNotExist: Failed lookup for key [errors] in 'None'
2017-08-22T03:04:44.840210Z [debug    ] Exception while resolving variable 'show' in template 'admin/change_list.html'. [django.template] 
Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 885, in _resolve_lookup
    current = current[bit]
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/context.py", line 75, in __getitem__
    raise KeyError(key)
KeyError: 'show'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 891, in _resolve_lookup
    if isinstance(current, BaseContext) and getattr(type(current), bit):
AttributeError: type object 'RequestContext' has no attribute 'show'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 900, in _resolve_lookup
    current = current[int(bit)]
ValueError: invalid literal for int() with base 10: 'show'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 907, in _resolve_lookup
    (bit, current))  # missing attribute
django.template.base.VariableDoesNotExist: Failed lookup for key [show] in "[{'True': True, 'False': False, 'None': None, 'csrf_token': <SimpleLazyObject: '...'>}]"
2017-08-22T03:04:44.843559Z [debug    ] Exception while resolving variable 'show' in template 'admin/change_list.html'. [django.template] 
Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 885, in _resolve_lookup
    current = current[bit]
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/context.py", line 75, in __getitem__
    raise KeyError(key)
KeyError: 'show'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 891, in _resolve_lookup
    if isinstance(current, BaseContext) and getattr(type(current), bit):
AttributeError: type object 'RequestContext' has no attribute 'show'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 900, in _resolve_lookup
    current = current[int(bit)]
ValueError: invalid literal for int() with base 10: 'show'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 907, in _resolve_lookup
    (bit, current))  # missing attribute
django.template.base.VariableDoesNotExist: Failed lookup for key [show] in "[{'True': True, 'False': False, 'None': None, 'csrf_token': <SimpleLazyObject: '...'>}]"
2017-08-22T03:04:44.847828Z [debug    ] Exception while resolving variable 'is_multipart' in template 'admin/change_list.html'. [django.template] 
Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 885, in _resolve_lookup
    current = current[bit]
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 893, in _resolve_lookup
    current = getattr(current, bit)
AttributeError: 'NoneType' object has no attribute 'is_multipart'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 900, in _resolve_lookup
    current = current[int(bit)]
ValueError: invalid literal for int() with base 10: 'is_multipart'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 907, in _resolve_lookup
    (bit, current))  # missing attribute
django.template.base.VariableDoesNotExist: Failed lookup for key [is_multipart] in 'None'
2017-08-22T03:04:44.850196Z [debug    ] Exception while resolving variable 'is_multipart' in template 'admin/change_list.html'. [django.template] 
Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 885, in _resolve_lookup
    current = current[bit]
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 893, in _resolve_lookup
    current = getattr(current, bit)
AttributeError: 'NoneType' object has no attribute 'is_multipart'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 900, in _resolve_lookup
    current = current[int(bit)]
ValueError: invalid literal for int() with base 10: 'is_multipart'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 907, in _resolve_lookup
    (bit, current))  # missing attribute
django.template.base.VariableDoesNotExist: Failed lookup for key [is_multipart] in 'None'
2017-08-22T03:04:45.017252Z [debug    ] Exception while resolving variable 'non_field_errors' in template 'admin/change_list.html'. [django.template] 
Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 885, in _resolve_lookup
    current = current[bit]
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 893, in _resolve_lookup
    current = getattr(current, bit)
AttributeError: 'NoneType' object has no attribute 'non_field_errors'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 900, in _resolve_lookup
    current = current[int(bit)]
ValueError: invalid literal for int() with base 10: 'non_field_errors'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 907, in _resolve_lookup
    (bit, current))  # missing attribute
django.template.base.VariableDoesNotExist: Failed lookup for key [non_field_errors] in 'None'
2017-08-22T03:04:45.020119Z [debug    ] Exception while resolving variable 'non_field_errors' in template 'admin/change_list.html'. [django.template] 
Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 885, in _resolve_lookup
    current = current[bit]
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 893, in _resolve_lookup
    current = getattr(current, bit)
AttributeError: 'NoneType' object has no attribute 'non_field_errors'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 900, in _resolve_lookup
    current = current[int(bit)]
ValueError: invalid literal for int() with base 10: 'non_field_errors'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/techdragon/code/test_project/venv/lib/python3.6/site-packages/django/template/base.py", line 907, in _resolve_lookup
    (bit, current))  # missing attribute
django.template.base.VariableDoesNotExist: Failed lookup for key [non_field_errors] in 'None'

Change History (2)

comment:1 by Samuel Bishop, 7 years ago

Description: modified (diff)

comment:2 by Tim Graham, 7 years ago

Component: Template systemcontrib.admin
Resolution: duplicate
Status: newclosed

I created #28526 to address the problem of verbose, often unhelpful logging of undefined variables.

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