Django TemplateSyntaxError - 'staticfiles' is not a registered tag library
If you have any of the following tags in your template:
{% load staticfiles %}{% load static from staticfiles %}{% load admin_static %}
Then replace it with:
{% load static %}
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.
- Try
{% load static %}
instead of{% load staticfiles %}
- If effect of CSS or any other files doesn't reflect in your template then also write following lines in the end of your
settings.py
file
STATIC_URL = '/static/'STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]VENV_PATH = os.path.dirname(BASE_DIR)STATIC_ROOT = os.path.join(VENV_PATH, 'static_root')
This worked for me using django 3.1.4.
{% load static %}<link rel"stylesheet" href = "{% static 'style.css' %}">