From 5ac5784c627f1bf822022d0c60b753441706f111 Mon Sep 17 00:00:00 2001 From: Andrew Pinkham Date: Sat, 22 Dec 2018 14:24:41 +0100 Subject: [PATCH] Fix #6341 - BaseUniqueForValidator uses instance Prevents partial updates to serializes with UniqueFor[Date,Month,Year]Validators from failing unnecessarily. --- rest_framework/validators.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rest_framework/validators.py b/rest_framework/validators.py index 2ea3e5ac1..444d4d497 100644 --- a/rest_framework/validators.py +++ b/rest_framework/validators.py @@ -204,6 +204,9 @@ class BaseUniqueForValidator(object): The `UniqueForValidator` classes always force an implied 'required' state on the fields they are applied to. """ + if hasattr(self, "instance") and self.instance is not None: + return + missing_items = { field_name: self.missing_message for field_name in [self.field, self.date_field]