What is the difference between {% load staticfiles %} and {% load static %}

The built-in static template tag “link[s] to static files that are saved in STATIC_ROOT“.

The staticfiles contrib app’s static template tag “uses the configured STATICFILES_STORAGE storage to create the full URL for the given relative path”, which is “especially useful when using a non-local storage backend to deploy files”.

The built-in static template tag’s documentation (linked to above) has a note that says to use the staticfiles contrib app’s static template tag “if you have an advanced use case such as using a cloud service to serve static files”, and it gives this example of doing so:

{% load static from staticfiles %}
<img src="https://stackoverflow.com/questions/24238496/{% static"images/hi.jpg" %}" alt="Hi!" />

You could use {% load staticfiles %} rather than {% load static from staticfiles %} if you want, but the latter is more explicit.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)