39

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?

codingcoding
  • 692
  • 1
  • 8
  • 13
  • 1
    It's just a message. It's recommending you do not use TEMPLATE_DEBUG. – Gocht Sep 07 '15 at 20:59
  • @Gocht Thank you. What is the correct way to enter this value in the TEMPLATES dict? I just commented out the lines I added to the dict and debug seems to work fine. Is it really even necessary to add anything to this dict? – codingcoding Sep 07 '15 at 21:00
  • 1
    It is necessary if you want to keep your code up to date. @Alasdair has given you a good answer. – Gocht Sep 07 '15 at 21:16

5 Answers5

83

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.

Alasdair
  • 253,590
  • 43
  • 477
  • 449
15

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',
            ]
        },
    },
]
Chase Roberts
  • 8,262
  • 10
  • 64
  • 118
OWADVL
  • 8,899
  • 6
  • 50
  • 66
14

From settings.py remove all this:

    TEMPLATE_DIRS = (
        os.path.join(BASE_DIR,  'templates'),
    )

Then add 'templates' here:

    TEMPLATES = [
    {
        ...
        'DIRS': [here],
        ...
            ],
        },
    },
]
dev.ICE
  • 141
  • 1
  • 2
8

This is the best solution:

Change this line to:

TEMPLATES[0]['OPTIONS']['debug'] = True

which should fix the warning.

I have found it here.

kenorb
  • 118,428
  • 63
  • 588
  • 624
1

In my setting.py in django, there is not this script :

TEMPLATE_DEBUG = DEBUG

and

'debug': DEBUG, 'DEBUG': DEBUG, 'TEMPLATE_DEBUG': DEBUG

Maybe you can try to remove them and run it again.

julian salas
  • 2,254
  • 16
  • 20
Joni
  • 21
  • 4