当我使用runserver时,它会发出以下警告消息:
(1_8.W001)Django 1.8中不推荐使用独立的TEMPLATE_*设置,TEMPLATES字典优先.您必须将以下设置的值放入默认的TEMPLATES dict:TEMPLATE_DEBUG.
Django文档:
"TEMPLATE_DEBUG从版本1.8开始不推荐使用:在DjangoTemplates后端的OPTIONS中设置'debug'选项."
这是我的settings.py与我徒劳的尝试修复它:
DEBUG = True
TEMPLATE_DEBUG = DEBUG
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'myapp/templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
'debug': DEBUG,
'DEBUG': DEBUG,
'TEMPLATE_DEBUG': DEBUG
},
}, ]
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么?
如果在django模板的渲染内部缺少模板,我会得到如下的异常.
经过很长时间的搜索,我找到了伪造的部分:
{% include form.template_name %}
Run Code Online (Sandbox Code Playgroud)
form.template_name在我的上下文中为空.
如何在不搜索小时数的情况下找到相关的模板名称?
我缺少像普通python代码一样的回溯."普通"python回溯向我展示了包含bug的文件和行.
/home/foo_fm_d/bin/python /usr/local/pycharm-community-4.5/helpers/pycharm/utrunner.py /home/foo_fm_d/src/foo-time/foo_time/tests/unit/views/user/test_preview_of_next_days.py::EditTestCase::test_preview_of_next_days true
Testing started at 09:26 ...
Error
Traceback (most recent call last):
File "/home/foo_fm_d/src/foo-time/foo_time/tests/unit/views/user/test_preview_of_next_days.py", line 11, in test_preview_of_next_days
self.admin_client.get(url)
File "/home/foo_fm_d/src/djangotools/djangotools/utils/testutils.py", line 275, in get
response = super(Client, self).get(path, data, **extra)
File "/home/foo_fm_d/local/lib/python2.7/site-packages/django/test/client.py", line 473, in get
response = super(Client, self).get(path, data=data, **extra)
File "/home/foo_fm_d/local/lib/python2.7/site-packages/django/test/client.py", line 280, in get
return self.request(**r)
File "/home/foo_fm_d/local/lib/python2.7/site-packages/django/test/client.py", line 444, in request
six.reraise(*exc_info)
File "/home/foo_fm_d/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 137, in get_response
response = response.render()
File …Run Code Online (Sandbox Code Playgroud)