搜索

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


发布时间: 2022-11-24 19:14:00    浏览次数:42 次

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

 

免责声明 TemplateSyntaxError: 'staticfiles' is not a registered tag library. Must be one of:,资源类别:文本, 浏览次数:42 次, 文件大小:-- , 由本站蜘蛛搜索收录2022-11-24 07:14:00。此页面由程序自动采集,只作交流和学习使用,本站不储存任何资源文件,如有侵权内容请联系我们举报删除, 感谢您对本站的支持。 原文链接:https://www.cnblogs.com/vPYer/p/16922934.html