aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/mixins.py
diff options
context:
space:
mode:
Diffstat (limited to 'rest_framework/mixins.py')
-rw-r--r--rest_framework/mixins.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/rest_framework/mixins.py b/rest_framework/mixins.py
index 8873e4ae..47e4edf7 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
@@ -32,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."
@@ -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)