Ever wondering what does {% load staticfiles %} mean?

It means Django will loop through all INSTALLED_APPS directory to look for a “templatetags” subdirectory.

If found, it will in turn look for a “staticfiles.py” file inside the templatetags subdirectory.

If staticfiles.py is found, then it will import it.

For example, if django.contrib.staticfiles is in the INSTALLED_APPS, then
{% load staticfiles %}
will import the following file:
There is a module level function called “static” defined in staticfiles.py, which is the “static” in the {% static %} template tag.

No comments: