I keep getting an error in the admin whenever I want to access it and it crashes the moment I deploy it in uWSGI. Here's the error:
DEBUG:django.template:Exception while resolving variable 'is_popup' in template 'admin/login.html'.
Traceback (most recent call last):
File "/home/leandro/.envs/********/lib/python3.4/site-packages/django/template/base.py", line 879, in _resolve_lookup
current = current[bit]
File "/home/leandro/.envs/*******/lib/python3.4/site-packages/django/template/context.py", line 77, in __getitem__
raise KeyError(key)
KeyError: 'is_popup'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/leandro/.envs/********/lib/python3.4/site-packages/django/template/base.py", line 885, in _resolve_lookup
if isinstance(current, BaseContext) and getattr(type(current), bit):
AttributeError: type object 'RequestContext' has no attribute 'is_popup'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/leandro/.envs/********/lib/python3.4/site-packages/django/template/base.py", line 894, in _resolve_lookup
current = current[int(bit)]
ValueError: invalid literal for int() with base 10: 'is_popup'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/leandro/.envs/******/lib/python3.4/site-packages/django/template/base.py", line 901, in _resolve_lookup
(bit, current)) # missing attribute
django.template.base.VariableDoesNotExist: Failed lookup for key [is_popup] in "[{'False': False, 'None': None, 'True': True}, {'MEDIA_URL': '/media/', 'DEFAULT_MESSAGE_LEVELS': {'ERROR': 40, 'WARNING': 30, 'INFO': 20, 'SUCCESS': 25, 'DEBUG': 10}, 'LANGUAGE_CODE': 'es-AR', 'messages': <django.contrib.messages.storage.fallback.FallbackStorage object at 0x7ff93002a8d0>, 'csrf_token': <SimpleLazyObject: <function csrf.<locals>._get_val at 0x7ff92b377d08>>, 'LANGUAGE_BIDI': False, 'TIME_ZONE': 'ART', 'STATIC_URL': '/static/', 'user': <SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x7ff93002a828>>, 'perms': <django.contrib.auth.context_processors.PermWrapper object at 0x7ff92b324c18>, 'LANGUAGES': [('af', 'Afrikaans'), ('ar', 'Arabic'), ('ast', 'Asturian'), ('az', 'Azerbaijani'), ('bg', 'Bulgarian'), ('be', 'Belarusian'), ('bn', 'Bengali'), ('br', 'Breton'), ('bs', 'Bosnian'), ('ca', 'Catalan'), ('cs', 'Czech'), ('cy', 'Welsh'), ('da', 'Danish'), ('de', 'German'), ('el', 'Greek'), ('en', 'English'), ('en-au', 'Australian English'), ('en-gb', 'British English'), ('eo', 'Esperanto'), ('es', 'Spanish'), ('es-ar', 'Argentinian Spanish'), ('es-co', 'Colombian Spanish'), ('es-mx', 'Mexican Spanish'), ('es-ni', 'Nicaraguan Spanish'), ('es-ve', 'Venezuelan Spanish'), ('et', 'Estonian'), ('eu', 'Basque'), ('fa', 'Persian'), ('fi', 'Finnish'), ('fr', 'French'), ('fy', 'Frisian'), ('ga', 'Irish'), ('gd', 'Scottish Gaelic'), ('gl', 'Galician'), ('he', 'Hebrew'), ('hi', 'Hindi'), ('hr', 'Croatian'), ('hu', 'Hungarian'), ('ia', 'Interlingua'), ('id', 'Indonesian'), ('io', 'Ido'), ('is', 'Icelandic'), ('it', 'Italian'), ('ja', 'Japanese'), ('ka', 'Georgian'), ('kk', 'Kazakh'), ('km', 'Khmer'), ('kn', 'Kannada'), ('ko', 'Korean'), ('lb', 'Luxembourgish'), ('lt', 'Lithuanian'), ('lv', 'Latvian'), ('mk', 'Macedonian'), ('ml', 'Malayalam'), ('mn', 'Mongolian'), ('mr', 'Marathi'), ('my', 'Burmese'), ('nb', 'Norwegian Bokmal'), ('ne', 'Nepali'), ('nl', 'Dutch'), ('nn', 'Norwegian Nynorsk'), ('os', 'Ossetic'), ('pa', 'Punjabi'), ('pl', 'Polish'), ('pt', 'Portuguese'), ('pt-br', 'Brazilian Portuguese'), ('ro', 'Romanian'), ('ru', 'Russian'), ('sk', 'Slovak'), ('sl', 'Slovenian'), ('sq', 'Albanian'), ('sr', 'Serbian'), ('sr-latn', 'Serbian Latin'), ('sv', 'Swedish'), ('sw', 'Swahili'), ('ta', 'Tamil'), ('te', 'Telugu'), ('th', 'Thai'), ('tr', 'Turkish'), ('tt', 'Tatar'), ('udm', 'Udmurt'), ('uk', 'Ukrainian'), ('ur', 'Urdu'), ('vi', 'Vietnamese'), ('zh-hans', 'Simplified Chinese'), ('zh-hant', 'Traditional Chinese')]}, {}, {'next': '/admin/', 'LANGUAGE_BIDI': False, 'available_apps': [], 'title': 'Identificarse', 'site_title': <django.utils.functional.lazy.<locals>.__proxy__ object at 0x7ff9369bd390>, 'site': <Site: example.com>, 'LANGUAGE_CODE': 'es-AR', 'site_name': 'example.com', 'site_url': '/', 'form': <AdminAuthenticationForm bound=False, valid=Unknown, fields=(username;password)>, 'has_permission': False, 'site_header': <django.utils.functional.lazy.<locals>.__proxy__ object at 0x7ff9369bd438>, 'app_path': '/admin/login/?next=/admin/'}]"
I've tried disabling all the admin sites I registered and I keep getting this error. Any ideas?
I was getting the same log message also, with fresh install of django 1.10.6. and logging turned on. I am not an expert on this, but here is what I found out, after asking a question on the Django-users mailing list.
As you can read from the Django logging documentation, the log levels are from the lowest priority to the highest priority
This means, it is actually "nice to know" low level information, which you will log if something fails, and you can not find a reason otherwise.
If you look at the first line of the exception, it says
Exception while resolving variable 'is_popup' in template 'admin/login.html'
The 'admin/index.html' extends 'base_site.html', which extends 'base.html', which has following lines (near the beginning of the file):
<body class="{% if is_popup %}popup {% endif %}{% block bodyclass %}{% endblock %}"
data-admin-utc-offset="{% now "Z" %}">
<!-- Container -->
<div id="container">
{% if not is_popup %}
<!-- Header -->
<div id="header">
<div id="branding">
{% block branding %}{% endblock %}
</div>
You can see from the django logging documentation that missing template variables cause DEBUG level log messages starting from Django 1.9.
The reason for the missing template variable is that django reuses templates. And in some cases, there will be a template variable 'is_popup' defined, and django will render the page differently. When there is no such variable as 'is_popup', django will skip the associated lines. I.e. undefined
and false
are identical for comparison purposes inside the template file. Of course you could write code to check if a variable exists, but it would just be extra line of code. Django will skip the undefined variable (some try .. exception pattern inside the core code) anyway.
Just include a logger with name "django.template
" to have the log level INFO only.
'loggers': {
'django': {
'handlers': ['file'],
'level': 'DEBUG',
'propagate': True,
},
'django.template': {
'handlers': ['file'],
'level': 'INFO',
'propagate': True,
},
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With