程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

django 報錯:‘staticfiles‘ is not a registered tag library. Must be one of:

編輯:Python

報錯內容如下:

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 %}

報錯解決

刷新頁面後報錯消失


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved