I'm using Django as restful APIs and found that session doesn't work if a view has a csrf_exempt decoration.
Here is some code:
@csrf_exempt
def scorer_login(request):
request.session['username'] = request.POST['username']
I found that request.session doesn't change at all when I print request.session.get('username') in other views.
However, if there isn't csrf_exempt, it works:
def scorer_login(request):
request.session['username'] = 'test_username'
How can I fix it?
Aucun commentaire:
Enregistrer un commentaire