Skip to content

Commit

Permalink
Create a session if none exists at first
Browse files Browse the repository at this point in the history
  • Loading branch information
mjumbewu committed May 4, 2012
1 parent 85f9053 commit 2cf8473
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion street_score/project/views.py
Expand Up @@ -42,9 +42,13 @@ class MainUIView (views.TemplateView):
def get_context_data(self, **kwargs):
context = super(MainUIView, self).get_context_data(**kwargs)

session_key = self.request.session.session_key
if not self.request.session.exists(session_key):
self.request.session.create()
session_key = self.request.session.session_key

# Using the browser session, get the current user info (or create it if
# none exists for the current session).
session_key = self.request.session.session_key
session = Session.objects.get(session_key=session_key)
user_info = UserInfo.objects.get_or_create(session=session)[0]

Expand Down

0 comments on commit 2cf8473

Please sign in to comment.