diff options
| author | Stephan Groß | 2012-11-05 11:45:49 +0100 |
|---|---|---|
| committer | Stephan Groß | 2012-11-05 11:45:49 +0100 |
| commit | 44449fa1f5f2d68740c9fb6a13c8e0a0eb41434c (patch) | |
| tree | c4b6d8ed8af239dd5651d9f6a18ddbfe2079bc07 /rest_framework/mixins.py | |
| parent | ff7725f05e8ca624e54d707f7c655e3d5c8b8888 (diff) | |
| parent | 5b397e50ddb999f85949a7359d0a26c3531c78a9 (diff) | |
| download | django-rest-framework-44449fa1f5f2d68740c9fb6a13c8e0a0eb41434c.tar.bz2 | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'rest_framework/mixins.py')
| -rw-r--r-- | rest_framework/mixins.py | 9 |
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) |
