python - django 1.10 在解析模板 'is_popup' 中的变量 'admin/login.html' 时出现异常

标签 python django

我用 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'

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

最佳答案

我遇到了这个错误,原来是因为我在我的主设置文件中放入了 SESSION_COOKIE_SECURE = True 而忘记将 SESSION_COOKIE_SECURE = False 放入我的开发设置(与 OP 一样,这是在使用 manage.py runserver 时进行的,因此安全 cookie 是不可能的)。

关于python - django 1.10 在解析模板 'is_popup' 中的变量 'admin/login.html' 时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40066019/

相关文章:

python - 将 Unicode 字符串转换为 Python 中的字符串(包含额外符号)

python - 一种热编码单分类数值列

python - Jinja 2 不会迭代我的 python 字典(从 Redis 读取)

python - 拥有一个可以属于其他两个模型中的任何一个的 django 模型(外键关系)

python - Python 中的正则化逻辑回归(Andrew ng 类(class))

python - django 形式的附加字段

用于用户/帐户设置的 Django 应用程序

django - Django属性简短描述

python - pytest:有没有办法报告测试的内存使用情况?

python - 我想将 .html 中的两个 id 发布到 View 中