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"""
|
||||
if isinstance(value, dict):
|
||||
return 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
|
||||
|
||||
try:
|
||||
value = json.loads(value)
|
||||
except: #this is required to load fixtures
|
||||
value = eval(value)
|
||||
assert isinstance(value, list)
|
||||
return tuple(value)
|
||||
|
||||
|
|
Loading…
Reference in a new issue