Django not able to find the static files when usin

2019-06-25 09:45发布

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条回答
太酷不给撩
2楼-- · 2019-06-25 10:18

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",
     )
查看更多
登录 后发表回答