From 308d03ba98111ab0a693b9bfe833806307427f7f Mon Sep 17 00:00:00 2001 From: "Philippe O. Wagner" Date: Thu, 17 Sep 2015 12:12:20 +0200 Subject: [PATCH] Docs update for ``TEMPLATES.OPTIONS.loaders`` config. Works for Django 1.8+ --- docs/overview.txt | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/docs/overview.txt b/docs/overview.txt index 8d67121..8c6c69d 100644 --- a/docs/overview.txt +++ b/docs/overview.txt @@ -24,21 +24,41 @@ Setup 'dbtemplates', ) - * Add ``dbtemplates.loader.Loader`` to the ``TEMPLATE_LOADERS`` list + * Add ``dbtemplates.loader.Loader`` to the ``TEMPLATES.OPTIONS.loaders`` list in the settings.py of your Django project. It should look something like this:: - TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', - 'dbtemplates.loader.Loader', - ) + TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [ # your template dirs here + ], + 'APP_DIRS': False, + 'OPTIONS': { + 'context_processors': [ + 'django.contrib.auth.context_processors.auth', + 'django.template.context_processors.debug', + 'django.template.context_processors.i18n', + 'django.template.context_processors.media', + 'django.template.context_processors.static', + 'django.template.context_processors.tz', + 'django.contrib.messages.context_processors.messages', + 'django.template.context_processors.request', + ], + 'loaders': [ + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', + 'dbtemplates.loader.Loader', + ], + }, + }, + ] - Order of TEMPLATE_LOADERS is important. In the former example, templates from database + Order of ``TEMPLATES.OPTIONS.loaders`` is important. In the former example, templates from database will be used as a fallback (ie. when template does not exists in other locations). If you want template from database to be used to override templates in other locations, - put ``dbtemplates.loader.Loader`` at beginning of ``TEMPLATE_LOADERS`` settting. + put ``dbtemplates.loader.Loader`` at beginning of ``loaders``. 4. Sync your database ``python manage.py syncdb`` 5. Restart your Django server