Lea*_*let 13 django django-admin
每当我想访问它时,我一直在管理员中收到错误,并且当我在uWSGI中部署它时它会崩溃.这是错误:
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/'}]"
Run Code Online (Sandbox Code Playgroud)
我已经尝试禁用我注册的所有管理站点,并且我一直收到此错误.有任何想法吗?
np8*_*np8 24
我也得到了相同的日志消息,全新安装了django 1.10.6.和日志记录打开.我不是这方面的专家,但在Django-users邮件列表上提问后,我发现了这一点.
您可以从Django 日志文档中读取,日志级别从最低优先级到最高优先级
这意味着,实际上"很高兴知道"低级别信息,如果出现故障您将记录,否则您无法找到原因.
如果你看一下例外的第一行,它会说
Exception while resolving variable 'is_popup' in template 'admin/login.html'
Run Code Online (Sandbox Code Playgroud)
'admin/index.html'扩展了'base_site.html',扩展了'base.html',它有以下行(靠近文件的开头):
<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>
Run Code Online (Sandbox Code Playgroud)
您可以从django 日志记录文档中看到,缺少模板变量会导致从Django 1.9开始的DEBUG级别日志消息.
缺少模板变量的原因是django重用模板.在某些情况下,会定义一个模板变量'is_popup',而django会以不同的方式呈现页面.当没有'is_popup'这样的变量时,django将跳过相关的行.即undefined,false在模板文件中用于比较目的是相同的.当然,您可以编写代码来检查变量是否存在,但它只是额外的代码行.Django无论如何都会跳过未定义的变量(一些尝试..核心代码中的异常模式).
只需包含一个名为" django.template" 的记录器,只能使用日志级别INFO.
'loggers': {
'django': {
'handlers': ['file'],
'level': 'DEBUG',
'propagate': True,
},
'django.template': {
'handlers': ['file'],
'level': 'INFO',
'propagate': True,
},
},
Run Code Online (Sandbox Code Playgroud)
fan*_*bin -4
您应该将项目日志记录级别设置为不在 debug.set 中,以 info 可以工作。
'loggers': {
'django': {
'handlers': ['file', 'console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
'propagate': True,
},
},
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5257 次 |
| 最近记录: |