How can I access the session in my models and views in Django?
What is the correct 开发者_运维知识库way to get information about the session in
- my models?
- my views?
Assuming that you have the sessions middleware enabled, you can access session
as a property of request which is passed into the view:
def my_view(request, *args, **kwargs):
print request.session['my_session_key']
django doc reference
精彩评论