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:

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:
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.