Error Django TemplateSyntaxError - staticfiles is not a registered tag library

0 votes

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

How to fix this?

Jul 29, 2020 in Python by kartik
• 37,520 points
16,296 views

1 answer to this question.

0 votes

Hello @kartik,

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')

Hope this helps!!

Thank You!!

answered Jul 29, 2020 by Niroj
• 82,840 points

Related Questions In Python

0 votes
1 answer

How to print a message or the error if a file is not found?

To print the message that file is not ...READ MORE

answered Jan 2, 2019 in Python by Omkar
• 69,220 points
2,904 views
0 votes
1 answer
0 votes
1 answer

Error: Name is not defined, It’s not returning a value

Remove main & try or  Use __name__ instead ...READ MORE

answered Oct 12, 2020 in Python by Gitika
• 65,770 points
1,189 views
0 votes
1 answer

How to temporarily disable a foreign key constraint in MySQL?

Hello @kartik, To turn off foreign key constraint ...READ MORE

answered Jun 23, 2020 in Python by Niroj
• 82,840 points
2,510 views
0 votes
1 answer

How do I use Django templates without the rest of Django?

Hello @kartik, Let's say you have this important ...READ MORE

answered Jun 23, 2020 in Python by Niroj
• 82,840 points
1,587 views
0 votes
1 answer

Input() error - NameError: name '…' is not defined

Hello @kartik, You should use raw_input if you are ...READ MORE

answered May 5, 2020 in Python by Niroj
• 82,840 points
23,243 views
0 votes
1 answer

Error: port is already in use of Django Server

Hii @kartik, Just type sudo fuser -k 8000/tcp. This ...READ MORE

answered May 6, 2020 in Python by Niroj
• 82,840 points
15,662 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP