Sometimes request.session.session_key is None

前端 未结 3 462
北恋
北恋 2021-01-04 09:56

I hit a problem when get session_key from request.session.

I am using Django1.8 and Python2.7.10 to set up a RESTful service.

Here is snippet of

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-04 10:13

    According to John's suggestion.

    I fixed the problem by this snippet:

    if not request.session.session_key:
        request.session.save()
    session_id = request.session.session_key
    

提交回复
热议问题