From 340b7f2a6d8a552399511cc87747d1223df48ec0 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Thu, 18 Apr 2013 10:04:04 +0200 Subject: [PATCH] Walkaround for jsonfield not decoding json on save. --- apps/sponsors/models.py | 4 ++++ 1 file changed, 4 insertions(+) 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(), -- 2.20.1