当使用非递归模板加载器时,Django1.11不能递归地扩展模板

2024-10-02 10:26:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我有django1.11.2,我安装了django mobile=0.7.0。在

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

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" %}

^{pr2}$

我的模板设置:

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']

中间件类:

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',
]

Tags: djangoauthadmin错误contexttemplateloadermobile
1条回答
网友
1楼 · 发布于 2024-10-02 10:26:16

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

'loaders': (
    'django_mobile.loader.Loader',
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
    'django.template.loaders.eggs.Loader',
),

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

相关问题 更多 >

    热门问题