Django TemplateSyntaxError - 'staticfiles' 不是注册的标签库 [英] Django TemplateSyntaxError - 'staticfiles' is not a registered tag library

查看:31
本文介绍了Django TemplateSyntaxError - 'staticfiles' 不是注册的标签库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

升级到 Django 3.0 后,我得到以下 TemplateSyntaxError:

After upgrading to Django 3.0, I get the following TemplateSyntaxError:

In template /Users/alasdair//myproject/myapp/templates/index.html, error at line 1
'staticfiles' is not a registered tag library. Must be one of: admin_list admin_modify admin_urls cache i18n l10n log static tz

这是我的模板

{% load staticfiles %}
<img src="{% static 'my_image.html' %}">

推荐答案

如果您的模板中有以下任何标签:

If you have any of the following tags in your template:

{% load staticfiles %}
{% load static from staticfiles %}
{% load admin_static %}

然后将其替换为:

{% load static %}

您必须进行此更改,因为 {% load staticfiles %}{% load admin_static %}已在 Django 2.1 中弃用已在 Django 3.0 中移除.

You have to make this change because {% load staticfiles %} and {% load admin_static %} were deprecated in Django 2.1, and removed in Django 3.0.

这篇关于Django TemplateSyntaxError - 'staticfiles' 不是注册的标签库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆