From c77632babb092b4c8fa524fe31f8817318459791 Mon Sep 17 00:00:00 2001 From: bradford281 Date: Fri, 22 May 2015 12:59:51 -0400 Subject: [PATCH] Update 3.0-announcement.md The recommended workaround for simulating the old "full_clean" method wouldn't work for update(), as the full set of attrs to build out the model instance would not be provided. --- docs/topics/3.0-announcement.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/topics/3.0-announcement.md b/docs/topics/3.0-announcement.md index 59fe779ca..5663a8683 100644 --- a/docs/topics/3.0-announcement.md +++ b/docs/topics/3.0-announcement.md @@ -237,7 +237,12 @@ The one difference that you do need to note is that the `.clean()` method will n There may be some cases where you really do need to keep validation logic in the model `.clean()` method, and cannot instead separate it into the serializer `.validate()`. You can do so by explicitly instantiating a model instance in the `.validate()` method. def validate(self, attrs): - instance = ExampleModel(**attrs) + if not self.instance: + instance = self.Meta.model(**attrs) + else: + instance = self.instance + for attr_name in attrs: + instance.attr_name = attrs.get('attr_name') instance.clean() return attrs