我使用python3.5和django1.10.0创建了一个新的django项目,每当我想访问localhost:8000/admin
时,我一直在管理员中收到错误,他就是错误:
[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'
任何人都可以帮助我,非常感谢!
答案 0 :(得分:2)
我遇到了这个错误,结果是因为我将SESSION_COOKIE_SECURE = True
放在了我的主要设置文件中,却忘记了将SESSION_COOKIE_SECURE = False
放在了我的开发设置中(与OP一样,使用manage.py runserver
,因此无法使用安全的Cookie)。