首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >django 1.11在使用非递归模板加载器时无法以递归方式扩展模板

django 1.11在使用非递归模板加载器时无法以递归方式扩展模板
EN

Stack Overflow用户
提问于 2018-02-20 21:26:41
回答 1查看 238关注 0票数 0

我安装了django 1.11.2,并且安装了django-mobile=0.7.0。

当我想要进入管理面板时,我收到一个错误:

代码语言:javascript
复制
ExtendsError at /admin/
Cannot extend templates recursively when using non-recursive template loaders
Request Method: GET
Request URL:    http://127.0.0.1:8000/admin/
Django Version: 1.11.2
Exception Type: ExtendsError
Exception Value:    
Cannot extend templates recursively when using non-recursive template loaders

我在第一行{% extends "admin/base.html" %}中收到错误

代码语言:javascript
复制
{% extends "admin/base.html" %}
{% load admin_static %}{% load suit_tags %}

{% block branding %} {% endblock branding %}

我的模板设置:

代码语言:javascript
复制
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(BASE_DIR, 'templates'),
        ],
        'APP_DIRS': False,
        'OPTIONS': {
            'context_processors': [
                'django.contrib.auth.context_processors.auth',
                'django.template.context_processors.debug',
                'django.template.context_processors.i18n',
                'django.template.context_processors.media',
                'django.template.context_processors.static',
                'django.template.context_processors.tz',
                'django.template.context_processors.csrf',
                'django.template.context_processors.request',
                'django.contrib.messages.context_processors.messages',
                'django_mobile.context_processors.flavour',
            ],
            'loaders': (
                'django.template.loaders.filesystem.Loader',
                'django.template.loaders.app_directories.Loader',
                'django.template.loaders.eggs.Loader',
                'django_mobile.loader.Loader',
            ),
            'debug': DEBUG,
        },
    },
]
TEMPLATE_LOADERS = TEMPLATES[0]['OPTIONS']['loaders']

中间件类:

代码语言:javascript
复制
MIDDLEWARE_CLASSES = [
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'django_mobile.middleware.MobileDetectionMiddleware',
    'django_mobile.middleware.SetFlavourMiddleware',
]
EN

回答 1

Stack Overflow用户

发布于 2018-02-20 22:01:12

自述文件中的installation instructions表示django_mobile.loader.Loader应该是loaders中的first项,例如:

代码语言:javascript
复制
'loaders': (
    'django_mobile.loader.Loader',
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
    'django.template.loaders.eggs.Loader',
),

目前,您已经将其放在了最后,所以Django将首先尝试使用其他加载器。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48886381

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档