I want to know which way is correct to serve static files in Django
. All are working but which one is the best way.
I have tried {{ STATIC_URL }}
in my templates. Which is working fine.
And then {% load static %}
and used {% static 'path/to/static/file' %}
to load static file.
And this one is also working.
{% load staticfiles %}
and then {% static 'path/to/static/file' %}
for loading static file.
I am confused which one is the correct and should be used. Please can someone explain it to me.
As far as i know {{ STATIC_URL }}
tag just uses the STATIC_URL
defined in settings.py
file.
But what does load static
and load staticfiles
does behind the scenes. I have tried the official documentation and this one