我在 postgres 中有一个类型为
custom_property
的专栏jsonb
。
我需要验证此列的有效负载。
payload:
{
"description": "test description3",
"custom_property": {
"access": "Yes"
}
}
我有一个序列化程序:
class MySerializer(serializers.Serializer):
description = serializers.CharField(required=False, max_length=500)
custom_property = serializers.DictField(required=False)
我应该为这个专栏使用
DictField
还是JSONField
?
看来在这两种情况下,都需要先用
json.dumps()
格式化为json字符串。