added RetrieveUpdateAPIView

This commit is contained in:
Stephan Groß 2012-12-13 16:57:17 +01:00
parent 497da7fc69
commit e198a2b376
3 changed files with 24 additions and 0 deletions

View File

@ -97,6 +97,14 @@ Provides `get` and `post` method handlers.
Extends: [MultipleObjectAPIView], [ListModelMixin], [CreateModelMixin] Extends: [MultipleObjectAPIView], [ListModelMixin], [CreateModelMixin]
## RetrieveUpdateAPIView
Used for **read or update** endpoints to represent a **single model instance**.
Provides `get` and `put` method handlers.
Extends: [SingleObjectAPIView], [RetrieveModelMixin], [UpdateModelMixin]
## RetrieveDestroyAPIView ## RetrieveDestroyAPIView
Used for **read or delete** endpoints to represent a **single model instance**. Used for **read or delete** endpoints to represent a **single model instance**.

View File

@ -4,6 +4,10 @@
> >
> — Eric S. Raymond, [The Cathedral and the Bazaar][cite]. > — Eric S. Raymond, [The Cathedral and the Bazaar][cite].
## Master
* Added `RetrieveUpdateAPIView`
## 2.1.9 ## 2.1.9
**Date**: 11th Dec 2012 **Date**: 11th Dec 2012

View File

@ -185,6 +185,18 @@ class ListCreateAPIView(mixins.ListModelMixin,
return self.create(request, *args, **kwargs) return self.create(request, *args, **kwargs)
class RetrieveUpdateAPIView(mixins.RetrieveModelMixin,
mixins.UpdateModelMixin,
SingleObjectAPIView):
"""
Concrete view for retrieving, updating a model instance.
"""
def get(self, request, *args, **kwargs):
return self.retrieve(request, *args, **kwargs)
def put(self, request, *args, **kwargs):
return self.update(request, *args, **kwargs)
class RetrieveDestroyAPIView(mixins.RetrieveModelMixin, class RetrieveDestroyAPIView(mixins.RetrieveModelMixin,
mixins.DestroyModelMixin, mixins.DestroyModelMixin,
SingleObjectAPIView): SingleObjectAPIView):