Commit fd84cf7f by Tom Christie

Docs tweaks

parent 2e3032ff
...@@ -30,8 +30,8 @@ As an example of just how simple REST framework APIs can now be, here's an API w ...@@ -30,8 +30,8 @@ As an example of just how simple REST framework APIs can now be, here's an API w
# Routers provide an easy way of automatically determining the URL conf # Routers provide an easy way of automatically determining the URL conf
router = routers.DefaultRouter() router = routers.DefaultRouter()
router.register(r'users', views.UserViewSet) router.register(r'users', UserViewSet)
router.register(r'groups', views.GroupViewSet) router.register(r'groups', GroupViewSet)
# Wire up our API using automatic URL routing. # Wire up our API using automatic URL routing.
......
...@@ -8,7 +8,7 @@ Let's introduce a couple of essential building blocks. ...@@ -8,7 +8,7 @@ Let's introduce a couple of essential building blocks.
REST framework introduces a `Request` object that extends the regular `HttpRequest`, and provides more flexible request parsing. The core functionality of the `Request` object is the `request.DATA` attribute, which is similar to `request.POST`, but more useful for working with Web APIs. REST framework introduces a `Request` object that extends the regular `HttpRequest`, and provides more flexible request parsing. The core functionality of the `Request` object is the `request.DATA` attribute, which is similar to `request.POST`, but more useful for working with Web APIs.
request.POST # Only handles form data. Only works for 'POST' method. request.POST # Only handles form data. Only works for 'POST' method.
request.DATA # Handles arbitrary data. Works any HTTP request with content. request.DATA # Handles arbitrary data. Works for 'POST', 'PUT' and 'PATCH' methods.
## Response objects ## Response objects
......
...@@ -119,7 +119,7 @@ Registering the viewsets with the router is similar to providing a urlpattern. ...@@ -119,7 +119,7 @@ Registering the viewsets with the router is similar to providing a urlpattern.
The `DefaultRouter` class we're using also automatically creates the API root view for us, so we can now delete the `api_root` method from our `views` module. The `DefaultRouter` class we're using also automatically creates the API root view for us, so we can now delete the `api_root` method from our `views` module.
## Trade-offs between views vs viewsets. ## Trade-offs between views vs viewsets
Using viewsets can be a really useful abstraction. It helps ensure that URL conventions will be consistent across your API, minimizes the amount of code you need to write, and allows you to concentrate on the interactions and representations your API provides rather than the specifics of the URL conf. Using viewsets can be a really useful abstraction. It helps ensure that URL conventions will be consistent across your API, minimizes the amount of code you need to write, and allows you to concentrate on the interactions and representations your API provides rather than the specifics of the URL conf.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment