gpt4 book ai didi

python - FutureWarning : `TemplateForHostMiddleware` is deprecated. 请升级到模板加载器

转载 作者:太空宇宙 更新时间:2023-11-04 02:23:45 24 4
gpt4 key购买 nike

我正在构建一个 mezzanine网站。

我通过键入 pip install mezzanine 安装了 mezzanine,这安装了 django 1.9 (IIRC) 和 mezzanine。

然后我安装了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.

我该如何解决此警告 - 因为警告不是很清楚(即升级哪个 模板加载器以及升级模板加载器是什么意思? )

最佳答案

参见 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 .

关于python - FutureWarning : `TemplateForHostMiddleware` is deprecated. 请升级到模板加载器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50967854/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com