thebjorn
thebjorn

Reputation: 27351

What is the correct way of loading the static template tag in Django?

The documentation is a bit ambiguous..

In https://docs.djangoproject.com/en/dev/howto/static-files/#configuring-static-files it says

{% load staticfiles %}

and in https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#template-tags it says

{% load static from staticfiles %}

(some of our templates just have {% load static %} although I'm not sure if that is actually working..?)

Upvotes: 0

Views: 709

Answers (1)

catavaran
catavaran

Reputation: 45585

Both ways are correct. But I always use {% load staticfiles %}.

{% static %} is the only tag in the staticfiles library so I don't see any reason to use the {% load static from staticfiles %} version.

As for the {% load static %} - this is a built-in template tag which has no relation with the staticfiles contrib app. If you don't use (and don't plan to use) any special STATICFILES_STORAGE then this version will work for you just fine.

Upvotes: 3

Related Questions