首页 > 其他分享 >TemplateSyntaxError: 'staticfiles' is not a registered tag library. Must be one of:

TemplateSyntaxError: 'staticfiles' is not a registered tag library. Must be one of:

时间:2022-11-24 19:11:32浏览次数:39  
标签:processors TemplateSyntaxError registered library django staticfiles context tem

django.template.exceptions.TemplateSyntaxError: 'staticfiles' is not a registered tag library. Must be one of:

在settings.py中添加:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR / 'templates']
        ,
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
            # 添加下面内容
            'libraries': {  # Adding this section should work around the issue.
                'staticfiles': 'django.templatetags.static',
            },
        },
    },
]

 

标签:processors,TemplateSyntaxError,registered,library,django,staticfiles,context,tem
From: https://www.cnblogs.com/vPYer/p/16922934.html

相关文章