django 1.10解决模板'admin / login.html'中的变量'is_popup'时发生异常 [英] django 1.10 Exception while resolving variable 'is_popup' in template 'admin/login.html'

查看:335
本文介绍了django 1.10解决模板'admin / login.html'中的变量'is_popup'时发生异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用python3.5和django1.10.0创建了一个新的django项目,每当我要访问 localhost:8000 / admin 时,我总是在管理员中遇到错误,是错误:

I create a new django project with python3.5 and django1.10.0,I keep getting an error in the admin whenever I want access localhost:8000/admin, He`re's the error:

[DEBUG]- Exception while resolving variable 'is_popup' in template 'admin/login.html'.
Traceback (most recent call last):
  File "C:\Python\Python35\lib\site-packages\django\template\base.py", line 885, in _resolve_lookup
    current = current[bit]
  File "C:\Python\Python35\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\Python35\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\Python35\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\Python35\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 "[{'True': True, 'None': None, 'False': False}, {'perms': <django.contrib.auth.context_processors.PermWrapper object at 0x04A2D1D0>, 'DEFAULT_MESSAGE_LEVELS': {'WARNING': 30, 'SUCCESS': 25, 'ERROR': 40, 'INFO': 20, 'DEBUG': 10}, 'user': <SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x04A0A590>>, 'messages': <django.contrib.messages.storage.fallback.FallbackStorage object at 0x04A0A490>, 'request': <WSGIRequest: GET '/admin/login/?next=/admin/'>, 'csrf_token': <SimpleLazyObject: <function csrf.<locals>._get_val at 0x04581C90>>}, {}, {'has_permission': False, 'username': '', 'site_title': <django.utils.functional.lazy.<locals>.__proxy__ object at 0x03CF82B0>, 'next': '/admin/', 'site': <django.contrib.sites.requests.RequestSite object at 0x04A0A6D0>, 'app_path': '/admin/login/?next=/admin/', 'site_url': '/', 'site_name': '127.0.0.1:8000', 'available_apps': [], 'LANGUAGE_BIDI': False, 'LANGUAGE_CODE': 'en-us', 'form': <AdminAuthenticationForm bound=False, valid=Unknown, fields=(username;password)>, 'site_header': <django.utils.functional.lazy.<locals>.__proxy__ object at 0x03CF8310>, 'title': 'Log in'}]"
2016-10-16 09:31:59,199 [Thread-7:11460] [django.template:929] [base:_resolve_lookup] [DEBUG]- Exception while resolving variable 'is_popup' in template 'admin/login.html'.
Traceback (most recent call last):
  File "C:\Python\Python35\lib\site-packages\django\template\base.py", line 885, in _resolve_lookup
    current = current[bit]
  File "C:\Python\Python35\lib\site-packages\django\template\context.py", line 75, in __getitem__
    raise KeyError(key)
KeyError: 'is_popup'

任何人可以帮助我,非常感谢!

Anyone can help me,thanks very much!

推荐答案

我遇到了此错误,结果是因为我把 SESSION_COOKIE_SECURE = True 在我的主设置文件中,忘记了将 SESSION_COOKIE_SECURE = False 放入我的开发设置中(与OP一样)是在使用 manage.py runserver 时,因此无法使用安全cookie)。

I came across this error, and it turned out to be because I had put SESSION_COOKIE_SECURE = True in my main settings file and forgotten to put SESSION_COOKIE_SECURE = False in my dev settings (as with the OP this was while using manage.py runserver, so secure cookies were not possible).

这篇关于django 1.10解决模板'admin / login.html'中的变量'is_popup'时发生异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆