django 报错:‘staticfiles‘ is not a registered tag library. Must be one of:

报错内容如下:

TemplateSyntaxError at /api/docs/
'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
Request Method:	GET
Request URL:	http://127.0.0.1:8081/api/docs/
Django Version:	3.2
Exception Type:	TemplateSyntaxError
Exception Value:	
'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
Exception Location:	D:\Python39\lib\site-packages\django\template\defaulttags.py, line 1036, in find_library
Python Executable:	D:\Python39\python.exe
Python Version:	3.9.7
Python Path:	
['D:\\course\\Devops\\cmdb\\devops_api',
 'D:\\course',
 'D:\\course\\Devops\\day05\\templates',
 'D:\\course\\Devops\\day1\\devops\\templates',
 'D:\\course\\Devops\\day04\\devops\\templates',
 'D:\\course\\out\\production\\course',
 'C:\\Users\\Q\\AppData\\Roaming\\JetBrains\\IntelliJIdea2021.1\\plugins\\python\\helpers\\pycharm_display',
 'D:\\Python39\\python39.zip',
 'D:\\Python39\\DLLs',
 'D:\\Python39\\lib',
 'D:\\Python39',
 'C:\\Users\\Q\\AppData\\Roaming\\Python\\Python39\\site-packages',
 'D:\\Python39\\lib\\site-packages',
 'D:\\Python39\\lib\\site-packages\\pip-21.3.1-py3.9.egg',
 'D:\\Python39\\lib\\site-packages\\win32',
 'D:\\Python39\\lib\\site-packages\\win32\\lib',
 'D:\\Python39\\lib\\site-packages\\Pythonwin',
 'C:\\Users\\Q\\AppData\\Roaming\\JetBrains\\IntelliJIdea2021.1\\plugins\\python\\helpers\\pycharm_matplotlib_backend']
Server time:	Fri, 01 Jul 2022 06:03:55 +0000

在这里插入图片描述

解决方法

页面往下滚动,找到红框内容
在这里插入图片描述
打开红框1位置的文件
将第二行
{% load staticfiles %}
改为
{% load static %}
在这里插入图片描述

报错解决

刷新页面后报错消失
在这里插入图片描述


版权声明:本文为qq_29974229原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。