From 99aee48d98508a72f1914a761949146d9a584b47 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 24 May 2012 14:39:41 +0000 Subject: [PATCH] django 1.4 only creates session if needed --- pandora/user/models.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandora/user/models.py b/pandora/user/models.py index c3acdf8d2..8d1400a35 100644 --- a/pandora/user/models.py +++ b/pandora/user/models.py @@ -89,7 +89,11 @@ class SessionData(models.Model): @classmethod def get_or_create(cls, request): + if not request.session.session_key: + request.session.save() + request.session.modified = True session_key = request.session.session_key + assert session_key if request.user.is_authenticated(): cls.objects.filter(user=request.user).update(session_key=session_key) data, created = cls.objects.get_or_create(session_key=session_key)