From f90ee0161ee1b47af34c14108c5eb193481a888e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Tue, 18 Feb 2014 13:25:39 +0100 Subject: [PATCH] fix: Make polls app work correctly with Django 1.6 Sets are not serializable to JSON and Django 1.6 uses this format to serialize session data by default. --- apps/polls/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/polls/models.py b/apps/polls/models.py index f73b97043..8e356683e 100644 --- a/apps/polls/models.py +++ b/apps/polls/models.py @@ -37,7 +37,7 @@ class Poll(models.Model): return self.items.all().aggregate(models.Sum('vote_count'))['vote_count__sum'] def voted(self, session): - return self.id in session.get(USED_POLLS_KEY, set()) + return self.id in session.get(USED_POLLS_KEY, []) class PollItem(models.Model): @@ -60,5 +60,5 @@ class PollItem(models.Model): def vote(self, session): self.vote_count = self.vote_count + 1 self.save() - session.setdefault(USED_POLLS_KEY, set()).add(self.poll.id) + session.setdefault(USED_POLLS_KEY, []).append(self.poll.id) session.save() -- 2.20.1