標籤:

django找不到模版?

django下跑起伺服器以後輸入網址報錯找不到模版。清理了工程下compiled files後,再次運行伺服器報警告:

WARNINGS:

?: (1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 and the TEMPLATES dictionary takes precedence. You must put the values of the following settings into your default TEMPLATES dict: TEMPLATE_DIRS.

System check identified 1 issue (0 silenced).

但是這把能夠找到模版。請問出現這個情況是什麼原因?


我是結帖的,剛剛親測通過:

加粗部分:

TEMPLATES = [

{

BACKEND: django.template.backends.django.DjangoTemplates,

DIRS: [os.path.join(BASE_DIR, 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,

],

},

},

]

The standalone TEMPLATE_* settings were deprecated in Django 1.8 and the TEMPLATES dictionary takes precedence. You must put the values of the following settings into your default TEMPLATES dict: TEMPLATE_DIRS.

這話的意思和gcc玩的那套一樣,說這TEMPLATE_DIRS玩意被人詬病,1.8版本裡面不想要了,建議塞入TEMPLATES

可能是哪個版本release的,可是我不想去看Release Note~~~你們誰有興趣可以去翻翻~


Add your template directory to the Base TEMPLATES setting under the DIRS dictionary

Like so:

TEMPLATES = [
{
BACKEND: django.template.backends.django.DjangoTemplates,
DIRS: [
root("templates"), #### Here ####
],
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,
],
},
},
]


推薦閱讀:

Django框架應用中models.py文件與資料庫操作問題?
Django中提示TemplateDoesNotExist?
Django 多線程問題是怎麼回事?
用Django學習設計網站後台有什麼好書可以入門和深入學習?
為什麼感覺django很難呢?

TAG:Django框架 |