I have a model with some fields and a unique together
:
....
class Meta(object):
unique_together = (\'device_identifier\', \'device_platform\
Django REST framework applies the UniqueTogetherValidator
on the serializer. You can remove this by override the validators
field in the serializer definition.
class ExampleSerializer(serializers.ModelSerializer):
class Meta:
validators = []
Note that this also removes the other unique-check validators that are applied on the model, which might not be the best idea. To avoid that, just override the get_unique_together_validators
method on the serializer, to ensure only unique-together check is removed.
class ExampleSerializer(serializers.ModelSerializer):
def get_unique_together_validators(self):
"""Overriding method to disable unique together checks"""
return []