Django: "No module named context_processors" error after reboot

The issue was that I had no TEMPLATES setting in settings.py as required after upgrading to Django 1.8. I'm not really clear why it was working on my PC using the Django server.

From the allauth docs, I pasted this into my settings file:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                # Already defined Django-related contexts here

                # `allauth` needs this from django
                'django.template.context_processors.request',
            ],
        },
    },
]

And copied the contents of my old TEMPLATE_DIRS setting into the DIRS definition for TEMPLATES. The final result looks like this:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                # Already defined Django-related contexts here

                # `allauth` needs this from django
                'django.template.context_processors.request',
            ],
        },
    },
]

According to the documentation for a recent allauth update, context_processors now need to be specified in the TEMPLATES setting and not TEMPLATE_CONTEXT_PROCESSORS setting.

Thanks to Joey Wilhelm for pointing me in the right direction on this.


I encountered the same problem but I am upgrading from 1.9.1 to 1.10. I found there's a little difference in the settings.

This is the code from 1.9.1

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

This is code for 1.10

TEMPLATES = [
{
    'BACKEND': 'django.template.backends.django.DjangoTemplates',
    'DIRS': [os.path.join(BASE_DIR, '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',
        ],
    },
},
]

The line django.core.context_processors.request is not valid in 1.10. Remove it and the code works well.


Just a tip: When a traceback doesn't provide you with the information you need to identify the exact line of code; It can be helpful to enable DEBUG mode, and open the page in the browser. There's this wonderful little local_vars element, where you can see local variable state when the traceback occurs. It can be super handy!

(In my case, it was related to changes within allauth)


In my case, I had to delete the following line in settings.py:

            'django.core.context_processors.csrf',

I rebooted the server and I didn't see that error again afterwards.