Pregunta

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.

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top