[Patchew-devel] [PATCH 1/9] models: JSONField default should be empty dictionary, not empty string

Paolo Bonzini pbonzini at redhat.com
Sat Aug 18 08:39:36 UTC 2018


Otherwise, you could have a situation the REST API returns an
empty string for a GET request, but JSONField complains when the
same empty string is passed as a PUT request.

Signed-off-by: Paolo Bonzini <pbonzini at redhat.com>
---
 api/models.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/api/models.py b/api/models.py
index ad89cf8..eea924f 100644
--- a/api/models.py
+++ b/api/models.py
@@ -56,7 +56,7 @@ class Result(models.Model):
                                   code='invalid')])
     log_entry = models.OneToOneField(LogEntry, on_delete=models.CASCADE,
                                      null=True)
-    data = jsonfield.JSONField()
+    data = jsonfield.JSONField(default={})
 
     class Meta:
         index_together = [('status', 'name')]
-- 
2.17.1





More information about the Patchew-devel mailing list