-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for namespaces in APIRoot.
- Loading branch information
Rocky Meza
committed
Dec 27, 2014
1 parent
3576834
commit d8a7e65
Showing
4 changed files
with
77 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from django.conf.urls import url, include | ||
|
||
from rest_framework import viewsets, mixins, routers | ||
|
||
from .test_routers import APIRootTestModel | ||
|
||
|
||
class APIRootTestViewSet(viewsets.ModelViewSet): | ||
model = APIRootTestModel | ||
|
||
|
||
class ListlessViewSet(mixins.RetrieveModelMixin, | ||
viewsets.GenericViewSet): | ||
model = APIRootTestModel | ||
|
||
|
||
router = routers.DefaultRouter() | ||
router.register(r'test-model', APIRootTestViewSet) | ||
|
||
|
||
listless_router = routers.DefaultRouter() | ||
# Avoid conflict with the api/ route. | ||
listless_router.root_view_name = 'listless-api-root' | ||
listless_router.register(r'full', APIRootTestViewSet, 'full') | ||
listless_router.register(r'listless', ListlessViewSet, 'listless') | ||
|
||
|
||
urlpatterns = [ | ||
url(r'^api/', include(router.urls)), | ||
url(r'^namespaced-api/', include(router.urls, namespace='api-namespace')), | ||
url(r'^listless/', include(listless_router.urls)), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters