From 960747d425d2f178cadc4110d1c5dc9e46f182ff Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 27 Jul 2016 15:15:53 +0100 Subject: [PATCH] Unique together checks should apply to fields that are read only, but have a default. --- rest_framework/serializers.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index 8c39202f4..d5e6b66ed 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -1396,9 +1396,8 @@ class ModelSerializer(Serializer): # cannot map to a field, and must be a traversal, so we're not # including those. field_names = { - field.source for field in self.fields.values() + field.source for field in self._writable_fields if (field.source != '*') and ('.' not in field.source) - and not field.read_only } # Note that we make sure to check `unique_together` both on the