from django.conf.urls import include, url from dynamic_rest.views import login, logout from dynamic_rest.routers import DynamicRouter from tests import viewsets router = DynamicRouter() router.register_resource(viewsets.UserViewSet) router.register_resource(viewsets.GroupViewSet) router.register_resource(viewsets.ProfileViewSet) router.register_resource(viewsets.LocationViewSet) router.register(r'cars', viewsets.CarViewSet) router.register(r'cats', viewsets.CatViewSet) router.register_resource(viewsets.DogViewSet) router.register_resource(viewsets.HorseViewSet) router.register_resource(viewsets.PermissionViewSet) router.register(r'zebras', viewsets.ZebraViewSet) # not canonical router.register(r'user_locations', viewsets.UserLocationViewSet) # the above routes are duplicated to test versioned prefixes router.register_resource(viewsets.CatViewSet, namespace='v2') # canonical router.register(r'v1/user_locations', viewsets.UserLocationViewSet) router.register(r'p/users', viewsets.PermissionsUserViewSet, namespace='p') router.register('login', login) router.register('logout', logout) urlpatterns = [url(r'^', include(router.urls))]
from django.conf.urls import include, patterns, url from dynamic_rest.routers import DynamicRouter from tests import viewsets router = DynamicRouter() router.register_resource(viewsets.UserViewSet) router.register_resource(viewsets.GroupViewSet) router.register_resource(viewsets.ProfileViewSet) router.register_resource(viewsets.LocationViewSet) router.register(r'cats', viewsets.CatViewSet) router.register_resource(viewsets.DogViewSet) router.register_resource(viewsets.HorseViewSet) router.register(r'zebras', viewsets.ZebraViewSet) # not canonical router.register(r'user_locations', viewsets.UserLocationViewSet) # the above routes are duplicated to test versioned prefixes router.register_resource(viewsets.CatViewSet, namespace='v2') # canonical router.register(r'v1/user_locations', viewsets.UserLocationViewSet) urlpatterns = patterns( '', url(r'^', include(router.urls)) )
from django.conf.urls import url, include from dynamic_rest.routers import DynamicRouter from .views import ParentViewSet, ChildViewSet crud_router = DynamicRouter() crud_router.register_resource(ParentViewSet) crud_router.register_resource(ChildViewSet) urlpatterns = [ url(r'^crud/', include(crud_router.urls)), ]
from django.contrib import admin from django.conf import settings from django.conf.urls import include, url from django.views.decorators.csrf import csrf_exempt import debug_toolbar from dynamic_rest.routers import DynamicRouter from graphene_django.views import GraphQLView from drest import views # auto-register views router = DynamicRouter() for name in dir(views): view = getattr(views, name) if isclass(view) and getattr(view, 'serializer_class', None): router.register_resource(view, namespace='api') urlpatterns = [ url(r'^', include(router.urls)), url(r'^admin/', admin.site.urls), url(r'^graphql', csrf_exempt(GraphQLView.as_view(graphiql=True))), ] if settings.DEBUG: urlpatterns = [ url(r'^__debug__/', include(debug_toolbar.urls)), ] + urlpatterns