Template loading

Django provides a convenient and powerful API for loading templates from the filesystem, with the goal of removing redundancy both in your template-loading calls and in your templates themselves. In order to use this template-loading API, first you'll need to tell the framework where you store your templates. The place to do this is in your settings file—the settings.py file that I mentioned last chapter, when I introduced the ROOT_URLCONF setting. If you're following along, open your settings.py and find the TEMPLATES setting. It's a list of configurations, one for each engine:

TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { # ... some options here ... }, ...

Get Mastering Django: Core now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.