0

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

cwhisperer
  • 1,478
  • 1
  • 32
  • 63

2 Answers2

1

As the warning is suggested,you need to move TEMPLATE_CONTEXT_PROCESSORS settings inside TEMPLATES settings,Like this :

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',
            "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',
)

So,all the TEMPLATE_CONTEXT_PROCESSORS will be inside TEMPLATES,with 'context_processors' settings,Thanks.

Prakhar Trivedi
  • 8,218
  • 3
  • 28
  • 35
0

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",
            ]
        }
    }
]
Kornikopic
  • 188
  • 1
  • 15
  • ok, the warning is gone but now I receive following error on my page: No module named 'allauth.account.context_processors' – cwhisperer Nov 29 '16 at 19:08
  • According to the documentation, there is no allauth context_processors: http://django-allauth.readthedocs.io/en/latest/installation.html – Kornikopic Nov 29 '16 at 19:22
  • 1
    I removed 'allauth.account.context_processors.account' and 'allauth.socialaccount.context_processors.socialaccount' and it works ... thx – cwhisperer Nov 29 '16 at 19:29