Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Changed JSONField to allow empty lists as value

  • Loading branch information...
commit 413e5190f62ed7369d2f0907b471c76b49501a5f 1 parent d6986f4
@dhepper authored
View
2  django_extensions/db/fields/json.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)
View
6 django_extensions/tests/json_field.py
@@ -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, [])
Please sign in to comment.
Something went wrong with that request. Please try again.