📜  drf 序列化器唯一在一起 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:10.101000             🧑  作者: Mango

代码示例1
class SomeSerializer(serializers.ModelSerializer):
    class Meta:
        model = Some
        fields = ('field1', 'field2')
        validators = [
            serializers.UniqueTogetherValidator(
                queryset=model.objects.all(),
                fields=('field1', 'field2'),
                message='Some custom message.'
            )
        ]