load fixtures
This commit is contained in:
parent
7c95743f5e
commit
d8903b5e2f
1 changed files with 8 additions and 4 deletions
|
@ -12,8 +12,10 @@ class DictField(models.TextField):
|
||||||
"""Convert our string value to python after we load it from the DB"""
|
"""Convert our string value to python after we load it from the DB"""
|
||||||
if isinstance(value, dict):
|
if isinstance(value, dict):
|
||||||
return value
|
return value
|
||||||
|
try:
|
||||||
value = json.loads(value)
|
value = json.loads(value)
|
||||||
|
except: #this is required to load fixtures
|
||||||
|
value = eval(value)
|
||||||
assert isinstance(value, dict)
|
assert isinstance(value, dict)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
@ -23,7 +25,6 @@ class DictField(models.TextField):
|
||||||
value = json.dumps(value)
|
value = json.dumps(value)
|
||||||
return super(DictField, self).get_db_prep_save(value)
|
return super(DictField, self).get_db_prep_save(value)
|
||||||
|
|
||||||
|
|
||||||
class TupleField(models.TextField):
|
class TupleField(models.TextField):
|
||||||
"""TupleField is a textfield that contains JSON-serialized tuples."""
|
"""TupleField is a textfield that contains JSON-serialized tuples."""
|
||||||
|
|
||||||
|
@ -35,7 +36,10 @@ class TupleField(models.TextField):
|
||||||
if isinstance(value, tuple):
|
if isinstance(value, tuple):
|
||||||
return value
|
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)
|
assert isinstance(value, list)
|
||||||
return tuple(value)
|
return tuple(value)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue