使用高版本Django出现 'staticfiles' is not a registered tag library.

使用Django开发项目,使用模板和静态变量,debug后出现错误:

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

admin_list
admin_modify
admin_static
admin_urls
cache
i18n
l10n
log
static
tz

 

经过查询后得知:

我使用的Django版本为3.0.3,此版本已经弃用staticfiles作为标签模板库。

https://docs.djangoproject.com/en/dev/internals/deprecation/#deprecation-removed-in-3-0

使用高版本Django出现 'staticfiles' is not a registered tag library._第1张图片

解决方法:

将原本的

{% load staticfiles %}

改为

{% load static %}

重新debug成功。

你可能感兴趣的:(Django)