Adjusted the documentation according to comments.

This commit is contained in:
Omer Katz 2014-12-24 10:58:26 +02:00
parent 670a78536f
commit bf7309ef72

View File

@ -21,32 +21,33 @@ Here's an example of a simple URL conf, that uses `SimpleRouter`.
router.register(r'accounts', AccountViewSet) router.register(r'accounts', AccountViewSet)
urlpatterns = router.urls urlpatterns = router.urls
A more common usage of routers is to include it in order to combine it with other patterns. A more common usage of routers is to append it in order to combine it with other patterns.
from django.conf.urls import patterns, include, url from django.conf.urls import url
from rest_framework import routers from rest_framework import routers
router = routers.SimpleRouter() router = routers.SimpleRouter()
router.register(r'users', UserViewSet) router.register(r'users', UserViewSet)
router.register(r'accounts', AccountViewSet) router.register(r'accounts', AccountViewSet)
urlpatterns = patterns('', urlpatterns = [
url(r'^forgot-password/$, ForgotPasswordFormView.as_view(), url(r'^forgot-password/$, ForgotPasswordFormView.as_view(),
url(r'^', include(router.urls)) ]
)
urlpatterns += router.urls
It is possible to namespace the router's views using Django's standard namespacing mechanism: It is possible to namespace the router's views using Django's standard namespacing mechanism:
from django.conf.urls import patterns, include, url from django.conf.urls import include, url
from rest_framework import routers from rest_framework import routers
router = routers.SimpleRouter() router = routers.SimpleRouter()
router.register(r'users', UserViewSet) router.register(r'users', UserViewSet)
router.register(r'accounts', AccountViewSet) router.register(r'accounts', AccountViewSet)
urlpatterns = patterns('', urlpatterns = [
url(r'^', include(router.urls, namespace='api')) url(r'^', include(router.urls, namespace='api'))
) ]
There are two mandatory arguments to the `register()` method: There are two mandatory arguments to the `register()` method: