Django TemplateSyntaxError - 'staticfiles' is not a registered tag library

情到浓时终转凉″ 提交于 2020-05-09 18:44:19

问题


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

Here is my template

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

回答1:


{% load staticfiles %} and {% load admin_static %} were deprecated in Django 2.1, and removed in Django 3.0.

If you have any of the following in your template:

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

You should replace the tag with simply:

{% load static %}



回答2:


In Django 3.0 you should use below tag instead:

{% load static %}



回答3:


It's due to upgrading to Django3.0, use as mentioned above.

{% load static %}


来源:https://stackoverflow.com/questions/55929472/django-templatesyntaxerror-staticfiles-is-not-a-registered-tag-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!