django.template.exceptions.TemplateSyntaxError: ‘staticfiles‘ is not a registered tag library报错

django.template.exceptions.TemplateSyntaxError: ‘staticfiles‘ is not a registered tag library报错,第1张

报错如下:

解决方法:
在settings.py加上

'libraries': {  # Adding this section should work around the issue.
            'staticfiles': 'django.templatetags.static'}

加上之后如下,即可成功访问了~

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(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',
            },
        },
    },
]

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/715593.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-25
下一篇 2022-04-25

发表评论

登录后才能评论

评论列表(0条)

保存