FutureWarning : `TemplateForHostMiddleware` is deprecated. Please upgrade to the template loader
I’m building a mezzanine website.
I installed mezzanine
by typing pip install mezzanine, which installed django 1.9 (IIRC) and mezzanine
.
Then I installed cartridge to upgrade django to version 1.10.8.
Now, when I run runserver
at the command line, I get the following warning at the command line:
/path/to/env/lib/python3.5/site-packages/django/core/handlers/base.py:58:
FutureWarning: TemplateForHostMiddleware` is deprecated. Please
upgrade to the template loader.
How do I fix this warning – because the warning is not very clear (i.e. which template loader to upgrade and what does upgrading template loader mean?). )
Solution
See also this portion’s documentation explaining what’s going on:
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", ] }, }, ]
It looks like this change to the documentation hasn’t been implemented yet http://mezzanine.jupo.org/docs/multi-tenancy.html .