diff options
| author | Tom Christie | 2012-10-08 12:52:56 +0100 |
|---|---|---|
| committer | Tom Christie | 2012-10-08 12:52:56 +0100 |
| commit | 52ba2e333375c6829fb89b6b43e4d19b2f2a86a4 (patch) | |
| tree | d45e35751961ae6cac9813a2af073098b32f7e7e /rest_framework/mixins.py | |
| parent | 4fd8ab17a3e935d72bb4ec25ed8f16a21ec2c0ef (diff) | |
| download | django-rest-framework-52ba2e333375c6829fb89b6b43e4d19b2f2a86a4.tar.bz2 | |
Fix #285
Diffstat (limited to 'rest_framework/mixins.py')
| -rw-r--r-- | rest_framework/mixins.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/rest_framework/mixins.py b/rest_framework/mixins.py index 46821f64..7cfbe030 100644 --- a/rest_framework/mixins.py +++ b/rest_framework/mixins.py @@ -77,16 +77,15 @@ class UpdateModelMixin(object): self.object = None serializer = self.get_serializer(data=request.DATA, instance=self.object) + if serializer.is_valid(): if self.object is None: - obj = serializer.object - # TODO: Make ModelSerializers return regular instances, - # not DeserializedObject - if hasattr(obj, 'object'): - obj = obj.object - self.update_urlconf_attributes(serializer.object.object) + # If PUT occurs to a non existant object, we need to set any + # attributes on the object that are implicit in the URL. + self.update_urlconf_attributes(serializer.object) self.object = serializer.save() return Response(serializer.data) + return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) def update_urlconf_attributes(self, obj): |
