HOST_THEMES在我的夹层项目中没有工作

时间:2016-07-21 09:39:14

标签: django django-cms mezzanine

我有一个mezzanine项目,我在其中添加了多个主题。 现在我想添加HOST_THEMES的功能,但它不起作用,我无法找到解决方案。

My project Directory with <code>flat</code> and <code>moderna</code> themes

这就是我将主题添加到INSTALLED_APPS的方式,HOST_THEMES添加了hosttheme

INSTALLED_APPS = (
    "flat",
    "moderna",
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.redirects",
    "django.contrib.sessions",
    "django.contrib.sites",
    "django.contrib.sitemaps",
    "django.contrib.staticfiles",
    "mezzanine.boot",
    "mezzanine.conf",
    "mezzanine.core",
    "mezzanine.generic",
    "mezzanine.pages",
    "mezzanine.blog",
    "mezzanine.forms",
    "mezzanine.galleries",
    "mezzanine.twitter",
    # "mezzanine.accounts",
    # "mezzanine.mobile",
)

HOST_THEMES = [('localhost', 'moderna'),]

问题 - 即使我使用了flat,也只会加载HOST_THEMES主题作为默认主题。我是否还需要更改其他设置?

1 个答案:

答案 0 :(得分:0)

确保您的settings.py包含:

"loaders": [
                "mezzanine.template.loaders.host_themes.Loader",
                "django.template.loaders.filesystem.Loader",
                "django.template.loaders.app_directories.Loader",
            ]

以下示例

 TEMPLATES = [
        {
            "BACKEND": "django.template.backends.django.DjangoTemplates",
            "DIRS": [
                os.path.join(PROJECT_ROOT, "templates")
            ],
            "OPTIONS": {
                "context_processors": [
                    "django.contrib.auth.context_processors.auth",
                    "django.contrib.messages.context_processors.messages",
                    "django.template.context_processors.debug",
                    "django.template.context_processors.i18n",
                    "django.template.context_processors.static",
                    "django.template.context_processors.media",
                    "django.template.context_processors.request",
                    "django.template.context_processors.tz",
                    "mezzanine.conf.context_processors.settings",
                    "mezzanine.pages.context_processors.page",
                ],
                "builtins": [
                    "mezzanine.template.loader_tags",
                ],
                "loaders": [
                    "mezzanine.template.loaders.host_themes.Loader",
                    "django.template.loaders.filesystem.Loader",
                    "django.template.loaders.app_directories.Loader",
                ]
            },
        },
    ]

来源: https://github.com/stephenmcd/mezzanine/blob/a6d425b5d318446d2711883f9c0db244c7e8d063/mezzanine/project_template/project_name/settings.py