在访问web页面时报错,详细日志如下:
django.template.exceptions.TemplateSyntaxError: ‘staticfiles’ is not a registered tag library. Must be one of:
admin_list
admin_modify
admin_urls
cache
i18n
l10n
log
rest_framework
static
tz
解决办法:
指定staticfiles
settings.py 文件中TEMPLATES中的OPTIONS添加 如下代码
'libraries': {
'staticfiles': 'django.templatetags.static',
},
完整的 TEMPLATES如下:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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': {
'staticfiles': 'django.templatetags.static',
},
},
},
]