From 6e3390d65a3a5c64eaa4828d9927c15e75c24d45 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 16 Feb 2013 00:35:34 +0000 Subject: [PATCH] fix default values from south migration --- ox/django/fields.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ox/django/fields.py b/ox/django/fields.py index e1df5c7..3199ff5 100644 --- a/ox/django/fields.py +++ b/ox/django/fields.py @@ -55,6 +55,8 @@ class DictField(models.TextField): """Convert our JSON object to a string before we save""" if value == None: return value + if isinstance(value, basestring): + value = eval(value) assert isinstance(value, dict) value = json.dumps(value, default=to_json) return super(DictField, self).get_db_prep_save(value, connection=connection) @@ -79,6 +81,10 @@ class TupleField(models.TextField): def get_db_prep_save(self, value, connection): """Convert our JSON object to a string before we save""" + if isinstance(value, basestring): + value = eval(value) + if isinstance(value, list): + value = tuple(value) assert isinstance(value, tuple) value = json.dumps(value, default=to_json) return super(TupleField, self).get_db_prep_save(value, connection=connection)