Permalink
Browse files

Changed JSONField to allow empty lists as value

  • Loading branch information...
dhepper committed Apr 21, 2012
1 parent d6986f4 commit 413e5190f62ed7369d2f0907b471c76b49501a5f
Showing with 6 additions and 2 deletions.
  1. +1 −1 django_extensions/db/fields/json.py
  2. +5 −1 django_extensions/tests/json_field.py
@@ -71,7 +71,7 @@ def __init__(self, *args, **kwargs):
def to_python(self, value):
"""Convert our string value to JSON after we load it from the DB"""
- if not value:
+ if value is None or value == '':
return {}
elif isinstance(value, basestring):
res = loads(value)
@@ -28,4 +28,8 @@ def tearDown(self):
def testCharFieldCreate(self):
j = TestModel.objects.create(a=6, j_field=dict(foo='bar'))
-
+
+ def testEmptyList(self):
+ j = TestModel.objects.create(a=6, j_field=[])
+ self.assertIsInstance(j.j_field, list)
+ self.assertEquals(j.j_field, [])

0 comments on commit 413e519

Please sign in to comment.