开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜