django-postman discards RequestContext

对着背影说爱祢 提交于 2019-12-12 03:08:18

问题


I installed django-postman to my project. Afterwards, I saw that when I login, it logs in to the user home but then whenever I click on a link, session goes out. It wants me to re-login.

I'm using context_instance=RequestContext(request) at each view. So what could be the problem?

This happened when I inserted the following:

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.core.context_processors.static',
    'django.core.context_processors.request',
)

Without static one, it event doesnt recognize STATIC_URL and discards CSS.


回答1:


Ok I found the problem. Default django configuration doesnt have TEMPLATE_CONTEXT_PROCESSORS written in settings.py file. When I write this:

TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.static',
'django.core.context_processors.request',
)

I override the default TEMPLATE_CONTEXT_PROCESSORS which is invisible:

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

So I should've added request to the end of this tuple.



来源:https://stackoverflow.com/questions/10189899/django-postman-discards-requestcontext

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