mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-24 00:04:16 +03:00
Remove router bit from viewset docs
This commit is contained in:
parent
e0020c5b03
commit
d75cebf756
|
@ -2,6 +2,11 @@
|
|||
|
||||
# ViewSets
|
||||
|
||||
> After routing has determined which controller to use for a request, your controller is responsible for making sense of the request and producing the appropriate output.
|
||||
>
|
||||
> — [Ruby on Rails Documentation][cite]
|
||||
|
||||
|
||||
Django REST framework allows you to combine the logic for a set of related views in a single class, called a `ViewSet`. In other frameworks you may also find conceptually similar implementations named something like 'Resources' or 'Controllers'.
|
||||
|
||||
A `ViewSet` class is simply **a type of class-based View, that does not provide any method handlers** such as `.get()` or `.post()`, and instead provides actions such as `.list()` and `.create()`.
|
||||
|
@ -128,18 +133,4 @@ By creating your own base `ViewSet` classes, you can provide common behavior tha
|
|||
|
||||
For advanced usage, it's worth noting the that `ViewSetMixin` class can also be applied to the standard Django `View` class. Doing so allows you to use REST framework's automatic routing, but don't want to use it's permissions, authentication and other API policies.
|
||||
|
||||
---
|
||||
|
||||
# Routers
|
||||
|
||||
Routers provide a convenient and simple shortcut for wiring up your application's URLs.
|
||||
|
||||
router = routers.DefaultRouter()
|
||||
router.register('^/', APIRoot, 'api-root')
|
||||
router.register('^users/', UserViewSet, 'user')
|
||||
router.register('^groups/', GroupViewSet, 'group')
|
||||
router.register('^accounts/', AccountViewSet, 'account')
|
||||
|
||||
urlpatterns = router.urlpatterns
|
||||
|
||||
[cite]: http://guides.rubyonrails.org/routing.html
|
Loading…
Reference in New Issue
Block a user