aboutsummaryrefslogtreecommitdiffstats
path: root/docs/api-guide
diff options
context:
space:
mode:
Diffstat (limited to 'docs/api-guide')
-rwxr-xr-xdocs/api-guide/authentication.md11
-rwxr-xr-xdocs/api-guide/generic-views.md3
-rw-r--r--docs/api-guide/responses.md2
-rw-r--r--docs/api-guide/routers.md2
-rw-r--r--docs/api-guide/viewsets.md14
5 files changed, 22 insertions, 10 deletions
diff --git a/docs/api-guide/authentication.md b/docs/api-guide/authentication.md
index 09491f02..8cf995b3 100755
--- a/docs/api-guide/authentication.md
+++ b/docs/api-guide/authentication.md
@@ -303,6 +303,10 @@ The command line to test the authentication looks like:
curl -H "Authorization: Bearer <your-access-token>" http://localhost:8000/api/
+### Alternative OAuth 2 implementations
+
+Note that [Django OAuth Toolkit][django-oauth-toolkit] is an alternative external package that also includes OAuth 2.0 support for REST framework.
+
---
# Custom authentication
@@ -347,6 +351,10 @@ The following third party packages are also available.
HTTP digest authentication is a widely implemented scheme that was intended to replace HTTP basic authentication, and which provides a simple encrypted authentication mechanism. [Juan Riaza][juanriaza] maintains the [djangorestframework-digestauth][djangorestframework-digestauth] package which provides HTTP digest authentication support for REST framework.
+## Django OAuth Toolkit
+
+The [Django OAuth Toolkit][django-oauth-toolkit] package provides OAuth 2.0 support, and works with Python 2.7 and Python 3.3+. The package is maintained by [Evonove][evonove] and uses the excelllent [OAuthLib][oauthlib]. The package is well documented, and comes as a recommended alternative for OAuth 2.0 support.
+
[cite]: http://jacobian.org/writing/rest-worst-practices/
[http401]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2
[http403]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.4
@@ -365,3 +373,6 @@ HTTP digest authentication is a widely implemented scheme that was intended to r
[django-oauth2-provider]: https://github.com/caffeinehit/django-oauth2-provider
[django-oauth2-provider-docs]: https://django-oauth2-provider.readthedocs.org/en/latest/
[rfc6749]: http://tools.ietf.org/html/rfc6749
+[django-oauth-toolkit]: https://github.com/evonove/django-oauth-toolkit
+[evonove]: https://github.com/evonove/
+[oauthlib]: https://github.com/idan/oauthlib
diff --git a/docs/api-guide/generic-views.md b/docs/api-guide/generic-views.md
index cd1bc7a1..67853ed0 100755
--- a/docs/api-guide/generic-views.md
+++ b/docs/api-guide/generic-views.md
@@ -92,7 +92,8 @@ May be overridden to provide dynamic behavior such as returning a queryset that
For example:
def get_queryset(self):
- return self.user.accounts.all()
+ user = self.request.user
+ return user.accounts.all()
#### `get_object(self)`
diff --git a/docs/api-guide/responses.md b/docs/api-guide/responses.md
index f83b8194..399b7c23 100644
--- a/docs/api-guide/responses.md
+++ b/docs/api-guide/responses.md
@@ -10,7 +10,7 @@ REST framework supports HTTP content negotiation by providing a `Response` class
The `Response` class subclasses Django's `SimpleTemplateResponse`. `Response` objects are initialised with data, which should consist of native Python primitives. REST framework then uses standard HTTP content negotiation to determine how it should render the final response content.
-There's no requirement for you to use the `Response` class, you can also return regular `HttpResponse` objects from your views if you want, but it provides a nicer interface for returning Web API responses.
+There's no requirement for you to use the `Response` class, you can also return regular `HttpResponse` or `StreamingHttpResponse` objects from your views if required. Using the `Response` class simply provides a nicer interface for returning content-negotiated Web API responses, that can be rendered to multiple formats.
Unless you want to heavily customize REST framework for some reason, you should always use an `APIView` class or `@api_view` function for views that return `Response` objects. Doing so ensures that the view can perform content negotiation and select the appropriate renderer for the response, before it is returned from the view.
diff --git a/docs/api-guide/routers.md b/docs/api-guide/routers.md
index f16fa946..b74b6e13 100644
--- a/docs/api-guide/routers.md
+++ b/docs/api-guide/routers.md
@@ -26,7 +26,7 @@ There are two mandatory arguments to the `register()` method:
Optionally, you may also specify an additional argument:
-* `base_name` - The base to use for the URL names that are created. If unset the basename will be automatically generated based on the `model` or `queryset` attribute on the viewset, if it has one.
+* `base_name` - The base to use for the URL names that are created. If unset the basename will be automatically generated based on the `model` or `queryset` attribute on the viewset, if it has one. Note that if the viewset does not include a `model` or `queryset` attribute then you must set `base_name` when registering the viewset.
The example above would generate the following URL patterns:
diff --git a/docs/api-guide/viewsets.md b/docs/api-guide/viewsets.md
index 79257e2a..25d11bfb 100644
--- a/docs/api-guide/viewsets.md
+++ b/docs/api-guide/viewsets.md
@@ -27,7 +27,7 @@ Let's define a simple viewset that can be used to list or retrieve all the users
queryset = User.objects.all()
serializer = UserSerializer(queryset, many=True)
return Response(serializer.data)
-
+
def retrieve(self, request, pk=None):
queryset = User.objects.all()
user = get_object_or_404(queryset, pk=pk)
@@ -69,7 +69,7 @@ The default routers included with REST framework will provide routes for a stand
"""
Example empty viewset demonstrating the standard
actions that will be handled by a router class.
-
+
If you're using format suffixes, make sure to also include
the `format=None` keyword argument for each action.
"""
@@ -103,12 +103,12 @@ For example:
class UserViewSet(viewsets.ModelViewSet):
"""
- A viewset that provides the standard actions
+ A viewset that provides the standard actions
"""
queryset = User.objects.all()
serializer_class = UserSerializer
-
- @action
+
+ @action()
def set_password(self, request, pk=None):
user = self.get_object()
serializer = PasswordSerializer(data=request.DATA)
@@ -197,7 +197,7 @@ As with `ModelViewSet`, you'll normally need to provide at least the `queryset`
Again, as with `ModelViewSet`, you can use any of the standard attributes and method overrides available to `GenericAPIView`.
-# Custom ViewSet base classes
+# Custom ViewSet base classes
You may need to provide custom `ViewSet` classes that do not have the full set of `ModelViewSet` actions, or that customize the behavior in some other way.
@@ -211,7 +211,7 @@ To create a base viewset class that provides `create`, `list` and `retrieve` ope
viewsets.GenericViewSet):
"""
A viewset that provides `retrieve`, `update`, and `list` actions.
-
+
To use it, override the class and set the `.queryset` and
`.serializer_class` attributes.
"""