mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 09:36:49 +03:00
Fix #2476
This commit is contained in:
parent
cf8a09993f
commit
0daf160946
|
@ -60,7 +60,7 @@ For example, you can append `router.urls` to a list of existing views…
|
|||
router.register(r'accounts', AccountViewSet)
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^forgot-password/$', ForgotPasswordFormView.as_view(),
|
||||
url(r'^forgot-password/$', ForgotPasswordFormView.as_view()),
|
||||
]
|
||||
|
||||
urlpatterns += router.urls
|
||||
|
@ -68,15 +68,15 @@ For example, you can append `router.urls` to a list of existing views…
|
|||
Alternatively you can use Django's `include` function, like so…
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^forgot-password/$', ForgotPasswordFormView.as_view(),
|
||||
url(r'^', include(router.urls))
|
||||
url(r'^forgot-password/$', ForgotPasswordFormView.as_view()),
|
||||
url(r'^', include(router.urls)),
|
||||
]
|
||||
|
||||
Router URL patterns can also be namespaces.
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^forgot-password/$', ForgotPasswordFormView.as_view(),
|
||||
url(r'^api/', include(router.urls, namespace='api'))
|
||||
url(r'^forgot-password/$', ForgotPasswordFormView.as_view()),
|
||||
url(r'^api/', include(router.urls, namespace='api')),
|
||||
]
|
||||
|
||||
If using namespacing with hyperlinked serializers you'll also need to ensure that any `view_name` parameters on the serializers correctly reflect the namespace. In the example above you'd need to include a parameter such as `view_name='api:user-detail'` for serializer fields hyperlinked to the user detail view.
|
||||
|
|
Loading…
Reference in New Issue
Block a user