about 1 year ago

I was running a django app on a linux machine and when I tried to login to the admin page, I kept getting redirected to the login page itself. It looks like this:

  1. POST /login/ 302
  2. GET / 302 < - should give me a 200 single I have logged in successfully but returns 302 instead
  3. GET ?next=/ 200 <- back to login page again

The site works when I use ./manage runserver but it wouldn't work when I use gunicorn to run it. I clear the cookie but it didn't work. I tried to set debug = False didn't work either. Eventially I found the problem, I wanted to use the database to store sessions, so I did this:

INSTALLED_APPS = (
    ...,
    django.contrib.sessions
)

SESSION_ENGIN = 'django.contrib.sessions.backends.cache'

For some reason, my session cache is messed up and I have to use this setting instead:

SESSION_ENGIN = 'django.contrib.sessions.backends.cached_db'

Instead of storing cache in memory which disappears after server restart, cached_db writes it to the database. I have used the cache option before and worked but not this time.

← How to setup pypi server Right shifting negative numbers in Javascript →
 
comments powered by Disqus