Django not able to find the static files when using django-allauth

元气小坏坏 提交于 2019-12-10 16:06:40

问题


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"

回答1:


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


来源:https://stackoverflow.com/questions/8445429/django-not-able-to-find-the-static-files-when-using-django-allauth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!