Yes, this is normal behavior. What you are seeing is the log output for a
missing template variable. Django logs these in log level debug.
See https://docs.djangoproject.com/en/1.10/topics/logging/#django-template
To get rid of these, you can configure the logger for the template system
to only log messages with loglevel INFO and higher.
'loggers': {
'django': {
'handlers': ['file'],
'level': 'DEBUG',
'propagate': True,
},
'django.template': {
'handlers': ['file'],
'level': 'INFO',
'propagate': True,
},
},
Hope that helps,
Daniel
https://consideratecode.com
On Friday, March 10, 2017 at 11:03:19 PM UTC+1, np wrote:
>
> Hello,
>
> I am a django newbie, just making my first django site. I tried to log the
> errors of my site, and found out
> KeyError: 'is_popup' ...
> when accessing http://127.0.0.1:8000/admin/.
>
> I tried this also on fresh install, django 1.10.6, using python 3.5.2. I
> had nothing else installed in the virtual environment, and the only lines I
> wrote to reproduce the error was to add
>
> LOGGING = {
> 'version': 1,
> 'disable_existing_loggers': False,
> 'handlers': {
> 'file': {
> 'level': 'DEBUG',
> 'class': 'logging.FileHandler',
> 'filename': r'C:\Tmp\testproject\log.txt',
> },
> },
> 'loggers': {
> 'django': {
> 'handlers': ['file'],
> 'level': 'DEBUG',
> 'propagate': True,
> },
> },
> }
>
> to the bottom of the settings.py.
>
> Then, on server startup (at http://127.0.0.1:8000) I got
>
> (0.000)
> SELECT name, type FROM sqlite_master
> WHERE type in ('table', 'view') AND NOT name='sqlite_sequence'
> ORDER BY name; args=None
> (0.000) SELECT "django_migrations"."app", "django_migrations"."name" FROM
> "django_migrations"; args=()
>
>
> and on first refresh of the page
> "GET / HTTP/1.1" 200 1767
>
> But, when accesing http://127.0.0.1:8000/admin/ I got
>
> (0.001) SELECT "django_session"."session_key",
> "django_session"."session_data", "django_session"."expire_date" FROM
> "django_session" WHERE ("django_session"."session_key" =
> 'ml9pjc4565zd009anzpufwpczy39fmpx' AND "django_session"."expire_date" >
> '2017-03-10 20:28:51.037208'); args=('ml9pjc4565zd009anzpufwpczy39fmpx',
> '2017-03-10 20:28:51.037208')
> (0.000) SELECT "auth_user"."id", "auth_user"."password",
> "auth_user"."last_login", "auth_user"."is_superuser",
> "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name",
> "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active",
> "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1;
> args=(1,)
> Exception while resolving variable 'is_popup' in template
> 'admin/index.html'.
> Traceback (most recent call last):
> File "C:\Python\Test\lib\site-packages\django\template\base.py", line
> 885, in _resolve_lookup
> current = current[bit]
> File "C:\Python\Test\lib\site-packages\django\template\context.py", line
> 75, in __getitem__
> raise KeyError(key)
> KeyError: 'is_popup'
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
> File "C:\Python\Test\lib\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 'is_popup'
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
> File "C:\Python\Test\lib\site-packages\django\template\base.py", line
> 900, 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 "C:\Python\Test\lib\site-packages\django\template\base.py", line
> 907, in _resolve_lookup
> (bit, current)) # missing attribute
> django.template.base.VariableDoesNotExist: Failed lookup for key
> [is_popup] in "[{'None': None, 'False': False, 'True': True}, {'perms':
> <django.contrib.auth.context_processors.PermWrapper object at
> 0x0000024B1D69BF28>, 'DEFAULT_MESSAGE_LEVELS': {'DEBUG': 10, 'INFO': 20,
> 'WARNING': 30, 'SUCCESS': 25, 'ERROR': 40}, 'csrf_token':
> <SimpleLazyObject: <function csrf.<locals>._get_val at
> 0x0000024B1D6148C8>>, 'request': <WSGIRequest: GET '/admin/'>, 'messages':
> <django.contrib.messages.storage.fallback.FallbackStorage object at
> 0x0000024B1D64E160>, 'user': <SimpleLazyObject: <User: admin>>}, {},
> {'LANGUAGE_CODE': 'en-us', 'LANGUAGE_BIDI': False, 'title':
> <django.utils.functional.lazy.<locals>.__proxy__ object at
> 0x0000024B1CB2F240>, 'has_permission': True, 'app_list': [{'models':
> [{'perms': {'add': True, 'delete': True, 'change': True}, 'admin_url':
> '/admin/auth/group/', 'add_url': '/admin/auth/group/add/', 'name':
> <django.utils.functional.lazy.<locals>.__proxy__ object at
> 0x0000024B1D66D860>, 'object_name': 'Group'}, {'perms': {'add': True,
> 'delete': True, 'change': True}, 'admin_url': '/admin/auth/user/',
> 'add_url': '/admin/auth/user/add/', 'name':
> <django.utils.functional.lazy.<locals>.__proxy__ object at
> 0x0000024B1D5AC710>, 'object_name': 'User'}], 'app_url': '/admin/auth/',
> 'name': <django.utils.functional.lazy.<locals>.__proxy__ object at
> 0x0000024B1CB2FCF8>, 'has_module_perms': True, 'app_label': 'auth'}],
> 'site_title': <django.utils.functional.lazy.<locals>.__proxy__ object at
> 0x0000024B1CB1BF28>, 'available_apps': [{'models': [{'perms': {'add': True,
> 'delete': True, 'change': True}, 'admin_url': '/admin/auth/group/',
> 'add_url': '/admin/auth/group/add/', 'name':
> <django.utils.functional.lazy.<locals>.__proxy__ object at
> 0x0000024B1D66D470>, 'object_name': 'Group'}, {'perms': {'add': True,
> 'delete': True, 'change': True}, 'admin_url': '/admin/auth/user/',
> 'add_url': '/admin/auth/user/add/', 'name':
> <django.utils.functional.lazy.<locals>.__proxy__ object at
> 0x0000024B1D66D048>, 'object_name': 'User'}], 'app_url': '/admin/auth/',
> 'name': <django.utils.functional.lazy.<locals>.__proxy__ object at
> 0x0000024B1CB2FCF8>, 'has_module_perms': True, 'app_label': 'auth'}],
> 'site_header': <django.utils.functional.lazy.<locals>.__proxy__ object at
> 0x0000024B1CB1BFD0>, 'site_url': '/'}]"
> Exception while resolving variable 'is_popup' in template
> 'admin/index.html'.
> Traceback (most recent call last):
> File "C:\Python\Test\lib\site-packages\django\template\base.py", line
> 885, in _resolve_lookup
> current = current[bit]
> File "C:\Python\Test\lib\site-packages\django\template\context.py", line
> 75, in __getitem__
> raise KeyError(key)
> KeyError: 'is_popup'
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
> File "C:\Python\Test\lib\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 'is_popup'
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
> File "C:\Python\Test\lib\site-packages\django\template\base.py", line
> 900, 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 "C:\Python\Test\lib\site-packages\django\template\base.py", line
> 907, in _resolve_lookup
> (bit, current)) # missing attribute
> django.template.base.VariableDoesNotExist: Failed lookup for key
> [is_popup] in "[{'None': None, 'False': False, 'True': True}, {'perms':
> <django.contrib.auth.context_processors.PermWrapper object at
> 0x0000024B1D69BF28>, 'DEFAULT_MESSAGE_LEVELS': {'DEBUG': 10, 'INFO': 20,
> 'WARNING': 30, 'SUCCESS': 25, 'ERROR': 40}, 'csrf_token':
> <SimpleLazyObject: <function csrf.<locals>._get_val at
> 0x0000024B1D6148C8>>, 'request': <WSGIRequest: GET '/admin/'>, 'messages':
> <django.contrib.messages.storage.fallback.FallbackStorage object at
> 0x0000024B1D64E160>, 'user': <SimpleLazyObject: <User: admin>>}, {},
> {'LANGUAGE_CODE': 'en-us', 'LANGUAGE_BIDI': False, 'title':
> <django.utils.functional.lazy.<locals>.__proxy__ object at
> 0x0000024B1CB2F240>, 'has_permission': True, 'app_list': [{'models':
> [{'perms': {'add': True, 'delete': True, 'change': True}, 'admin_url':
> '/admin/auth/group/', 'add_url': '/admin/auth/group/add/', 'name':
> <django.utils.functional.lazy.<locals>.__proxy__ object at
> 0x0000024B1D66D860>, 'object_name': 'Group'}, {'perms': {'add': True,
> 'delete': True, 'change': True}, 'admin_url': '/admin/auth/user/',
> 'add_url': '/admin/auth/user/add/', 'name':
> <django.utils.functional.lazy.<locals>.__proxy__ object at
> 0x0000024B1D5AC710>, 'object_name': 'User'}], 'app_url': '/admin/auth/',
> 'name': <django.utils.functional.lazy.<locals>.__proxy__ object at
> 0x0000024B1CB2FCF8>, 'has_module_perms': True, 'app_label': 'auth'}],
> 'site_title': <django.utils.functional.lazy.<locals>.__proxy__ object at
> 0x0000024B1CB1BF28>, 'available_apps': [{'models': [{'perms': {'add': True,
> 'delete': True, 'change': True}, 'admin_url': '/admin/auth/group/',
> 'add_url': '/admin/auth/group/add/', 'name':
> <django.utils.functional.lazy.<locals>.__proxy__ object at
> 0x0000024B1D66D470>, 'object_name': 'Group'}, {'perms': {'add': True,
> 'delete': True, 'change': True}, 'admin_url': '/admin/auth/user/',
> 'add_url': '/admin/auth/user/add/', 'name':
> <django.utils.functional.lazy.<locals>.__proxy__ object at
> 0x0000024B1D66D048>, 'object_name': 'User'}], 'app_url': '/admin/auth/',
> 'name': <django.utils.functional.lazy.<locals>.__proxy__ object at
> 0x0000024B1CB2FCF8>, 'has_module_perms': True, 'app_label': 'auth'}],
> 'site_header': <django.utils.functional.lazy.<locals>.__proxy__ object at
> 0x0000024B1CB1BFD0>, 'site_url': '/'}]"
> (0.001) SELECT "django_admin_log"."id", "django_admin_log"."action_time",
> "django_admin_log"."user_id", "django_admin_log"."content_type_id",
> "django_admin_log"."object_id", "django_admin_log"."object_repr",
> "django_admin_log"."action_flag", "django_admin_log"."change_message",
> "auth_user"."id", "auth_user"."password", "auth_user"."last_login",
> "auth_user"."is_superuser", "auth_user"."username",
> "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email",
> "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined",
> "django_content_type"."id", "django_content_type"."app_label",
> "django_content_type"."model" FROM "django_admin_log" INNER JOIN
> "auth_user" ON ("django_admin_log"."user_id" = "auth_user"."id") LEFT OUTER
> JOIN "django_content_type" ON ("django_admin_log"."content_type_id" =
> "django_content_type"."id") WHERE "django_admin_log"."user_id" = 1 ORDER BY
> "django_admin_log"."action_time" DESC LIMIT 10; args=(1,)
> "GET /admin/ HTTP/1.1" 200 2782
> "GET /static/admin/css/base.css HTTP/1.1" 304 0
> "GET /static/admin/css/dashboard.css HTTP/1.1" 304 0
> "GET /static/admin/css/fonts.css HTTP/1.1" 304 0
> "GET /static/admin/fonts/Roboto-Light-webfont.woff HTTP/1.1" 304 0
> "GET /static/admin/fonts/Roboto-Bold-webfont.woff HTTP/1.1" 304 0
> "GET /static/admin/fonts/Roboto-Regular-webfont.woff HTTP/1.1" 304 0
> "GET /static/admin/img/icon-addlink.svg HTTP/1.1" 304 0
> "GET /static/admin/img/icon-changelink.svg HTTP/1.1" 304 0
>
>
> I see similar KeyError: 'is_popup' also i my logfile on my main
> development site. Is this normal behaviour, or is this a bug?
>
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/36ecb8b2-25d2-4198-adb1-4a7de46f0b1b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.