0

Do I have to write {% load staticfiles %} when importing CSS files in my Django templates using {{ STATIC_URL }} template tag

<link href="{{ STATIC_URL }}abc/xyz/form.css" rel="stylesheet" type="text/css"> 

1 Answer 1

2

No, all you need is 'django.template.context_processors.static' included in the context_processors section of the TEMPLATES' OPTIONS in your settings.py.

Sign up to request clarification or add additional context in comments.

2 Comments

And what in case of <script src="{% static 'common/js/jquery.js' %}" type="text/javascript"></script>
In that case, {% load static %} or {% load staticfiles %} is necessary - nb. in Django 1.10 {% load staticfiles %} exists for backward compatibility and will probably be deprecated in 2.0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.