FutureWarning:“TemplateForHostMiddleware”已弃用。请升级到模板加载器
FutureWarning: `TemplateForHostMiddleware` is deprecated. Please upgrade to the template loader
我正在建立一个 mezzanine 网站。
我通过键入 pip install mezzanine
安装了夹层,这安装了 django 1.9 (IIRC) 和夹层。
然后我安装了 cartridge,将 django 升级到版本 1.10.8。
现在当我在命令行 运行 runserver
时,我在命令行收到以下警告:
/path/to/env/lib/python3.5/site-packages/django/core/handlers/base.py:58:
FutureWarning: TemplateForHostMiddleware` is deprecated. Please
upgrade to the template loader.
我该如何解决这个警告 - 因为警告不是很清楚(即升级 which 模板加载器还有什么这意味着升级模板加载器?)
请参阅文档的 this portion,其中解释了正在发生的事情:
Mezzanine implements host-specific templates using a template loader since version 4.3. Prior to that, the TemplateForHostMiddleware
was used. If you are upgrading from a version lower than 4.3 and getting warnings in the terminal about TemplateForHostMiddleware
, edit your settings.py to switch to the new loader-based approach:
- Remove
TemplateForHostMiddleware
from your MIDDLEWARE
or MIDDLEWARE_CLASSES
setting.
- Remove
"APP_DIRS": True
from your TEMPLATES
setting.
- Add
mezzanine.template.loaders.host_themes.Loader
to the list of template loaders.
Your TEMPLATES setting should look like this (notice the "loaders" key):
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [...],
"OPTIONS": {
"context_processors": [...],
"builtins": [...],
"loaders": [
"mezzanine.template.loaders.host_themes.Loader",
"django.template.loaders.filesystem.Loader",
"django.template.loaders.app_directories.Loader",
]
},
},
]
看起来对文档的这一更改尚未实现 http://mezzanine.jupo.org/docs/multi-tenancy.html。
我正在建立一个 mezzanine 网站。
我通过键入 pip install mezzanine
安装了夹层,这安装了 django 1.9 (IIRC) 和夹层。
然后我安装了 cartridge,将 django 升级到版本 1.10.8。
现在当我在命令行 运行 runserver
时,我在命令行收到以下警告:
/path/to/env/lib/python3.5/site-packages/django/core/handlers/base.py:58: FutureWarning: TemplateForHostMiddleware` is deprecated. Please upgrade to the template loader.
我该如何解决这个警告 - 因为警告不是很清楚(即升级 which 模板加载器还有什么这意味着升级模板加载器?)
请参阅文档的 this portion,其中解释了正在发生的事情:
Mezzanine implements host-specific templates using a template loader since version 4.3. Prior to that, the
TemplateForHostMiddleware
was used. If you are upgrading from a version lower than 4.3 and getting warnings in the terminal aboutTemplateForHostMiddleware
, edit your settings.py to switch to the new loader-based approach:
- Remove
TemplateForHostMiddleware
from yourMIDDLEWARE
orMIDDLEWARE_CLASSES
setting.- Remove
"APP_DIRS": True
from yourTEMPLATES
setting.- Add
mezzanine.template.loaders.host_themes.Loader
to the list of template loaders.Your TEMPLATES setting should look like this (notice the "loaders" key):
TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", "DIRS": [...], "OPTIONS": { "context_processors": [...], "builtins": [...], "loaders": [ "mezzanine.template.loaders.host_themes.Loader", "django.template.loaders.filesystem.Loader", "django.template.loaders.app_directories.Loader", ] }, }, ]
看起来对文档的这一更改尚未实现 http://mezzanine.jupo.org/docs/multi-tenancy.html。