From 3dd53f5bfe62d0f08ca8c1b07efe26726a99c276 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Tue, 2 Oct 2012 11:48:45 +0100 Subject: [PATCH] Latest docs build --- api-guide/generic-views.html | 59 ++++++++++++++++++++++++++++++++++++ api-guide/views.html | 1 + 2 files changed, 60 insertions(+) diff --git a/api-guide/generic-views.html b/api-guide/generic-views.html index 33927ff0d..4534f0596 100644 --- a/api-guide/generic-views.html +++ b/api-guide/generic-views.html @@ -95,6 +95,23 @@
@@ -108,6 +125,48 @@

Django’s generic views... were developed as a shortcut for common usage patterns... They take certain common idioms and patterns found in view development and abstract them so that you can quickly write common views of data without having to repeat yourself.

Django Documentation

+

One of the key benefits of class based views is the way they allow you to compose bits of reusable behaviour. REST framework takes advantage of this by providing a number of pre-built views that provide for commonly used patterns.

+

Example

+

...

+
+

API Reference

+

ListAPIView

+

Used for read-write endpoints to represent a collection of model instances.

+

Provides a get method handler.

+

ListCreateAPIView

+

Used for read-write endpoints to represent a collection of model instances.

+

Provides get and post method handlers.

+

RetrieveAPIView

+

Used for read-only endpoints to represent a single model instance.

+

Provides a get method handler.

+

RetrieveUpdateDestroyAPIView

+

Used for read-write endpoints to represent a single model instance.

+

Provides get, put and delete method handlers.

+
+

Base views

+

BaseAPIView

+

Extends REST framework's APIView class, adding support for serialization of model instances and model querysets.

+

MultipleObjectBaseAPIView

+

Provides a base view for acting on a single object, by combining REST framework's APIView, and Django's MultipleObjectMixin.

+

See also: ccbv.co.uk documentation for MultipleObjectMixin.

+

SingleObjectBaseAPIView

+

Provides a base view for acting on a single object, by combining REST framework's APIView, and Django's SingleObjectMixin.

+

See also: ccbv.co.uk documentation for SingleObjectMixin.

+
+

Mixins

+

The mixin classes provide the actions that are used

+

ListModelMixin

+

Provides a .list(request, *args, **kwargs) method, that implements listing a queryset.

+

CreateModelMixin

+

Provides a .create(request, *args, **kwargs) method, that implements creating and saving a new model instance.

+

RetrieveModelMixin

+

Provides a .retrieve(request, *args, **kwargs) method, that implements returning an existing model instance in a response.

+

UpdateModelMixin

+

Provides a .update(request, *args, **kwargs) method, that implements updating and saving an existing model instance.

+

DestroyModelMixin

+

Provides a .destroy(request, *args, **kwargs) method, that implements deletion of an existing model instance.

+

MetadataMixin

+

Provides a .metadata(request, *args, **kwargs) method, that returns a response containing metadata about the view.

diff --git a/api-guide/views.html b/api-guide/views.html index 4e40aced9..5e2b1ad40 100644 --- a/api-guide/views.html +++ b/api-guide/views.html @@ -178,6 +178,7 @@ This method is used to enforce permissions and throttling, and perform content n

.finalize_response(self, request, response, args, *kwargs)

Ensures that any Response object returned from the handler method will be rendered into the correct content type, as determined by the content negotation.

You won't typically need to override this method.

+

Function Based Views

Saying [that Class based views] is always the superior solution is a mistake.