From d8903b5e2f1153bf03b21e56b5d60e94c5c30d98 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 8 Feb 2010 20:34:18 +0530 Subject: [PATCH] load fixtures --- oxdjango/fields.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/oxdjango/fields.py b/oxdjango/fields.py index e556ecc..a169aa8 100644 --- a/oxdjango/fields.py +++ b/oxdjango/fields.py @@ -12,8 +12,10 @@ class DictField(models.TextField): """Convert our string value to python after we load it from the DB""" if isinstance(value, dict): return value - - value = json.loads(value) + try: + value = json.loads(value) + except: #this is required to load fixtures + value = eval(value) assert isinstance(value, dict) return value @@ -23,7 +25,6 @@ class DictField(models.TextField): value = json.dumps(value) return super(DictField, self).get_db_prep_save(value) - class TupleField(models.TextField): """TupleField is a textfield that contains JSON-serialized tuples.""" @@ -35,7 +36,10 @@ class TupleField(models.TextField): if isinstance(value, tuple): return value - value = json.loads(value) + try: + value = json.loads(value) + except: #this is required to load fixtures + value = eval(value) assert isinstance(value, list) return tuple(value)