Browse Source

perf: m2m json field 字段必填

pull/10672/head
ibuler 1 year ago
parent
commit
5708e57631
  1. 4
      apps/common/db/fields.py

4
apps/common/db/fields.py

@ -552,9 +552,13 @@ class JSONManyToManyField(models.JSONField):
if val["type"] == "ids":
if not isinstance(val["ids"], list):
raise ValueError(_("Invalid ids for ids, should be a list"))
if not val["ids"]:
raise ValueError(_("This field is required."))
elif val["type"] == "attrs":
if not isinstance(val["attrs"], list):
raise ValueError(_("Invalid attrs, should be a list of dict"))
if not val["attrs"]:
raise ValueError(_("This field is required."))
for attr in val["attrs"]:
if not isinstance(attr, dict):
raise ValueError(_("Invalid attrs, should be a list of dict"))

Loading…
Cancel
Save