From 027c9079f62322fe933bdfd4438f23cf4848e3cc Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 31 Oct 2012 20:11:32 +0000 Subject: PUT as create should return 201. Fixes #340. --- rest_framework/mixins.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'rest_framework/mixins.py') diff --git a/rest_framework/mixins.py b/rest_framework/mixins.py index 8873e4ae..0f2a0d93 100644 --- a/rest_framework/mixins.py +++ b/rest_framework/mixins.py @@ -3,9 +3,6 @@ Basic building blocks for generic class based views. We don't bind behaviour to http method handlers yet, which allows mixin classes to be composed in interesting ways. - -Eg. Use mixins to build a Resource class, and have a Router class - perform the binding of http methods to actions for us. """ from django.http import Http404 from rest_framework import status @@ -78,15 +75,17 @@ class UpdateModelMixin(object): def update(self, request, *args, **kwargs): try: self.object = self.get_object() + success_status = status.HTTP_200_OK except Http404: self.object = None + success_status = status.HTTP_201_CREATED serializer = self.get_serializer(data=request.DATA, instance=self.object) if serializer.is_valid(): self.pre_save(serializer.object) self.object = serializer.save() - return Response(serializer.data) + return Response(serializer.data, status=success_status) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) -- cgit v1.2.3 From 9a0cc7c720d40f7d2408672c49a5d8bfb62c3979 Mon Sep 17 00:00:00 2001 From: Pavel Savchenko Date: Thu, 1 Nov 2012 15:06:11 +0200 Subject: since MultipleObjectBaseView was renamed MultipleObjectAPIView, it stands to reason to complete the renaming in docs and comments as well. --- rest_framework/mixins.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'rest_framework/mixins.py') diff --git a/rest_framework/mixins.py b/rest_framework/mixins.py index 0f2a0d93..47e4edf7 100644 --- a/rest_framework/mixins.py +++ b/rest_framework/mixins.py @@ -29,7 +29,7 @@ class CreateModelMixin(object): class ListModelMixin(object): """ List a queryset. - Should be mixed in with `MultipleObjectBaseView`. + Should be mixed in with `MultipleObjectAPIView`. """ empty_error = u"Empty list and '%(class_name)s.allow_empty' is False." -- cgit v1.2.3