cwhisperer cwhisperer - 6 days ago 6
Python Question

Django AllAuth Warning

I'm new to Django and installed the AllAuth package and every seems to work fine. I followed different tutorials but each time I execute the command python manage.py runserver I receive a warning:


WARNINGS:
?: (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_CONTEXT_PROCESSORS.


Here a part of my settings.py:

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')]
,
'APP_DIRS': True,
'OPTIONS': {
'debug': DEBUG,
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'sekizai.context_processors.sekizai',
],
},
},
]
TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.request",
"django.contrib.auth.context_processors.auth",
"allauth.account.context_processors.account",
"allauth.socialaccount.context_processors.socialaccount",
)
AUTHENTICATION_BACKENDS = (
# Needed to login by username in Django admin, regardless of `allauth`
'django.contrib.auth.backends.ModelBackend',

# `allauth` specific authentication methods, such as login by e-mail
'allauth.account.auth_backends.AuthenticationBackend',
)


Any help is appreciated. Regards

Answer

Django regrouped all TEMPLATE_* vars into TEMPLATES var since Django 1.8+

https://docs.djangoproject.com/en/1.8/topics/templates/

This means you can move this part of the code in your TEMPLATE var:

"allauth.account.context_processors.account",
"allauth.socialaccount.context_processors.socialaccount",

And delete this:

TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.request",
"django.contrib.auth.context_processors.auth",
"allauth.account.context_processors.account",
"allauth.socialaccount.context_processors.socialaccount",
)

Final result:

TEMPLATES = [
    {
        # ...
        'OPTIONS': {
            # ...
            'context_processor': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'sekizai.context_processors.sekizai',
                "allauth.account.context_processors.account",
                "allauth.socialaccount.context_processors.socialaccount",
            ]
        }
    }
]
Comments