From: Radek Czajka Date: Thu, 18 Apr 2013 08:04:04 +0000 (+0200) Subject: Walkaround for jsonfield not decoding json on save. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/340b7f2a6d8a552399511cc87747d1223df48ec0 Walkaround for jsonfield not decoding json on save. --- diff --git a/apps/sponsors/models.py b/apps/sponsors/models.py index 24d302208..cbc8d9ba4 100644 --- a/apps/sponsors/models.py +++ b/apps/sponsors/models.py @@ -2,6 +2,7 @@ # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # +import json import time from StringIO import StringIO from django.db import models @@ -85,6 +86,9 @@ class SponsorPage(models.Model): html = property(fget=html) def save(self, *args, **kwargs): + if isinstance(self.sponsors, basestring): + # Walkaround for weird jsonfield 'no-decode' optimization. + self.sponsors = json.loads(self.sponsors) self.render_sprite() self._html = render_to_string('sponsors/page.html', { 'sponsors': self.populated_sponsors(),