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

Paolo Bonzini posted 9 patches 6 years, 8 months ago
There is a newer version of this series
[Patchew-devel] [PATCH 1/9] models: JSONField default should be empty dictionary, not empty string
Posted by Paolo Bonzini 6 years, 8 months ago
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@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


_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel