Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django app works fine, but getting a TEMPLATE_* warning message

When I use runserver, it gives this warning message:

(1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 and the TEMPLATES dictionary takes precedence. You must put the values of the following settings into your default TEMPLATES dict: TEMPLATE_DEBUG.

Quoth the Django Documentation:

"TEMPLATE_DEBUG Deprecated since version 1.8: Set the 'debug' option in the OPTIONS of a DjangoTemplates backend instead."

Here is my settings.py with my futile attempts to fix it:

DEBUG = True  TEMPLATE_DEBUG = DEBUG  TEMPLATES = [     {         'BACKEND': 'django.template.backends.django.DjangoTemplates',         'DIRS': [os.path.join(BASE_DIR, 'myapp/templates')],         'APP_DIRS': True,         'OPTIONS': {             'context_processors': [                 'django.template.context_processors.debug',                 'django.template.context_processors.request',                 'django.contrib.auth.context_processors.auth',                 'django.contrib.messages.context_processors.messages',             ],             'debug': DEBUG,             'DEBUG': DEBUG,             'TEMPLATE_DEBUG': DEBUG         },     }, ] 

What am I missing here?

like image 824
codingcoding Avatar asked Sep 07 '15 20:09

codingcoding


People also ask

What does {% %} mean in Django?

{% %} and {{ }} are part of Django templating language. They are used to pass the variables from views to template. {% %} is basically used when you have an expression and are called tags while {{ }} is used to simply access the variable.

What is Django template context?

A context is a variable name -> variable value mapping that is passed to a template. Context processors let you specify a number of variables that get set in each context automatically – without you having to specify the variables in each render() call.

What is load in Django template?

For a hands-on example of creating HTML pages with templates, see Tutorial 3. Django defines a standard API for loading and rendering templates regardless of the backend. Loading consists of finding the template for a given identifier and preprocessing it, usually compiling it to an in-memory representation.

What is Django templating engine?

Django's template engine provides a powerful mini-language for defining the user-facing layer of your application, encouraging a clean separation of application and presentation logic. Templates can be maintained by anyone with an understanding of HTML; no knowledge of Python is required.


2 Answers

Set debug in OPTIONS dictionary of your templates settings.

DEBUG = True  TEMPLATES = [     {         ...         'OPTIONS': {             'debug': DEBUG,         },     }, ] 

Then remove this line from your settings to stop the warnings

TEMPLATE_DEBUG = DEBUG 

See the Django docs for detailed instructions how to update your template settings.

like image 161
Alasdair Avatar answered Sep 22 '22 07:09

Alasdair


remove APP_DIRS and add the loaders inside the templates. example:

TEMPLATES = [     {         'BACKEND': 'django.template.backends.django.DjangoTemplates',         'DIRS': [os.path.join(BASE_DIR, 'templates')]         ,         'OPTIONS': {             'context_processors': [                 'django.template.context_processors.debug',                 'django.template.context_processors.request',                 'django.contrib.auth.context_processors.auth',                 'django.contrib.messages.context_processors.messages',             ],             'loaders': [                'django_jinja.loaders.AppLoader',                 'django_jinja.loaders.FileSystemLoader',             ]         },     }, ] 
like image 22
OWADVL Avatar answered Sep 21 '22 07:09

OWADVL