4

When I use allauth, everything seems to work fine except that Django is now unable to find the static files. Without allauth all the static files are being rendered. the settings for allauth requires to add

TEMPLATE_CONTEXT_PROCESSORS = (

    "allauth.context_processors.allauth",
    "allauth.account.context_processors.account"
)

I did not have TEMPLATE_CONTEXT_PROCESSORS in my settings file earlier. Is there something that I am missing? How should I solve this problem. When I see the DEBUG console I can see it is trying to fetch the css file as

"GET /accounts/login/css/contact.css"

whereas it should be doing

"GET /static/css/contact.css"
Sachin
  • 3,672
  • 9
  • 55
  • 96

1 Answers1

7

There's a default value for TEMPLATE_CONTEXT_PROCESSORS and you're overriding that one. So now the default ones are missing. And one of them is "django.core.context_processors.static", which is why Django can't find your static files.

See https://docs.djangoproject.com/en/1.3/ref/settings/#template-context-processors for the default list. What you need is the following:

 TEMPLATE_CONTEXT_PROCESSORS = (
     "django.contrib.auth.context_processors.auth",
     "django.core.context_processors.debug",
     "django.core.context_processors.i18n",
     "django.core.context_processors.media",
     "django.core.context_processors.static",
     "django.contrib.messages.context_processors.messages",
     "allauth.context_processors.allauth",
     "allauth.account.context_processors.account",
     )
Reinout van Rees
  • 13,486
  • 2
  • 36
  • 68
  • Thanks for the help... Actually up til now I had not been using TEMPLATE_CONTEXT_PROCESSORS and the thing were working fine... I have not understood the significance of TEMPLATE_CONTEXT_PROCESSORS, because everything works fine without that also, could you please explain what the reason is? – Sachin Dec 09 '11 at 16:51
  • I don't know "allauth", so I also don't know what its context processors do. I'd assume it puts some 'account' in your templates' context. If you your self don't use that, you won't miss the lack of the context processor. You might want to check if allauth's own templates all work. – Reinout van Rees Dec 09 '11 at 23:42
  • Is there a way how to get the default value in settings.py from a django module? – Petr Peller Oct 24 '13 at 07:45
  • 1
    @PetrPeller: I guess you mean something like `from django.conf import global-settings`? That's the full default list of settings. – Reinout van Rees Oct 25 '13 at 10:35
  • Deprecated (as in 2017): http://django-allauth.readthedocs.io/en/latest/installation.html --> `# Specify the context processors as follows: 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', ], }, },]` – ThePhi Dec 06 '17 at 15:59