liveBook · Manning

TEMPLATES setting

As explained in Django in Action

The TEMPLATES setting is the Django settings configuration that selects template engines and controls where template files are searched for.

The TEMPLATES setting tells Django which template engine to use and where to search for template files. It connects a view’s render() call with an HTML file on disk. section 3.10 section 3.6

A typical configuration controls the main lookup and rendering pieces:

  • BACKEND selects Django’s template backend. section 3.6

Rendering RiffMates news

A news() view passes request, "news.html", and a data dictionary to render(). With TEMPLATES['DIRS'] set to BASE_DIR / 'templates', Django can find templates/news.html and render the news list from the context. section 3.6

How Django in Action covers it

How deep it goes
Defines backend, directory, application lookup, and context-processor options, but does not descend into template-engine internals.
Examples
Uses RiffMates’ news() view, templates/news.html, a news list, and BASE_DIR / 'templates'.
What it assumes
Assumes a Django project with settings.py, views, render(), and templates; demonstrates the configuration through a working page.
What you can do after
Operate/configure Django template lookup so render() can locate and populate project HTML templates.
How it connects
Connects settings.py with template engines, views, render(), template context, and HTML templates.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Django in Action. The section links point to the parts of the book it draws on.