What does "load" do in Django Templates?

django, django-templates, function, python, templatetags

Solution

"weblog" after "load" (in template file `django_website/templates/base_weblog.html`) refers to file `weblog.py` in folder `django_website/apps/blog/templatetags`. Folder `templatetags` must be named exactly that and must contain a file named `__init__.py` (question 2).

"load" makes the custom template tags (`render_latest_blog_entries` and `render_month_links` in this case) available for use in templates, `django_website\templates\base_weblog.html` in this case. "Load" is a security and performance function.

Problem

As "load" is far too generic for searching: What is the purpose of "load" and what does it do in this particular case? - in a template file, base_weblog.html, `{% load weblog %}{% render_month_links %}` Are some naming conventions used in order for "load" to do its job? E.g. names of folders and/or files and/or class names? Where is the documentation for "load" and can you elaborate? Details: The example is from the source for http://www.djangoproject.com/ - direct download URL is through http://shrinkster.com/17g8. Partial folder structure (items with no file extension are folders): ``` django_website apps accounts aggregator blog urls.py models.py class Entry(models.Model) templatetags weblog.py contact docs templates base_weblog.html aggregator blog entry_archive.html entry_archive_year.html month_links_snippet.html entry_archive_month.html entry_detail.html entry_snippet.html entry_archive_day.html comments contact docs feeds flatfiles flatpages registration ```

Original source