Reputation: 10256
I have installed django-redis-session
via pip
and add this settings to the settings.py
file:
SESSION_ENGINE = 'redis_sessions.session'
When I go to the terminal and type:
$ redis-cli monitor
I can see there are changes when I log in and log out (using python-social-auth).
My question is: How can I get the session (from redis) based on the user?
If I call is_authenticated()
User's function it works, but my DB's (PostgreSQL) Session table has 0 rows.
Fianlly, is there any way to write the session key and data manually? I will need to use a complex PK for session based in two fields stored in redis.
Upvotes: 1
Views: 4541
Reputation: 308799
You should be able to get the current session with request.session
. This should work, whichever session backend you use, whether or not the user is logged in.
See the docs on using sessions in views for more info.
Upvotes: 3