Permalink
Browse files

Create a session if none exists at first

  • Loading branch information...
mjumbewu committed May 4, 2012
1 parent 85f9053 commit 2cf847370b44b5042912fe26688281b9fd061769
Showing with 5 additions and 1 deletion.
  1. +5 −1 street_score/project/views.py
@@ -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]

0 comments on commit 2cf8473

Please sign in to comment.