Using the Built-in Template Reference

Django’s admin interface includes a complete reference of all template tags and filters available for a given site. It’s designed to be a tool that Django programmers give to template developers. To see it, go to the admin interface and click the Documentation link at the upper right of the page.

The reference is divided into four sections: tags, filters, models, and views. The tags and filters sections describe all the built-in tags (in fact, the tag and filter references in Chapter 4 come directly from those pages) as well as any custom tag or filter libraries available. The views page is the most valuable. Each URL in your site has a separate entry here. If the related view includes a docstring, clicking the URL will show you the following:

  • The name of the view function that generates that view
  • A short description of what the view does
  • The context, or a list of variables available in the view’s template
  • The name of the template or templates that are used for that view

For a detailed example of view documentation, read the source code for Django’s generic object_list view, which is in django/views/generic/list_detail.py. Because Django-powered sites usually use database objects, the models pages describe each type of object in the system along with all the fields available on that object. Taken together, the documentation pages should tell you every tag, filter, variable, and object available to you in a given template.

Back to Tutorial

Share this post
[social_warfare]
Writing Custom Template Loaders
Configuring the Template System in Standalone Mode

Get industry recognized certification – Contact us

keyboard_arrow_up