【发布时间】:2018-02-10 10:52:56
【问题描述】:
我有一个带有一些字段的模型和一个unique together:
....
class Meta(object):
unique_together = ('device_identifier', 'device_platform',)
显然,通过这种方式,关于 Django REST 框架序列化程序,当我尝试使用相同的 device_identifier 和 device_platform 进行 PUT 时出现错误(如果已经存在包含此数据的条目)。
{
"non_field_errors": [
"The fields device_identifier, device_platform must make a unique set."
]
}
是否可以在我的模型序列化程序中禁用此验证? 因为我需要在保存模型步骤期间管理这种情况(对我来说,在序列化程序验证中这不是错误)
【问题讨论】:
标签: django python-2.7 serialization django-rest-framework unique