Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. from django.contrib import admin
  2. from django.urls import path, include
  3. from django.contrib.auth.models import User
  4. from authors.views import UserViewSet, AuthorViewSet, BookViewSet
  5. from rest_framework.routers import DefaultRouter
  6.  
  7. from rest_framework import routers
  8. from rest_framework.authtoken.views import obtain_auth_token
  9.  
  10.  
  11. # Routers provide an easy way of automatically determining the URL conf.
  12.  
  13. router = DefaultRouter()
  14. router.register(r'api/users', UserViewSet, basename='user')
  15. router.register(r'api/authors', AuthorViewSet, basename='author')
  16. router.register(r'api/books', BookViewSet, basename='book')
  17.  
  18.  
  19. # Wire up our API using automatic URL routing.
  20. # Additionally, we include login URLs for the browsable API.
  21. urlpatterns = [
  22. path('admin/', admin.site.urls),
  23. path(r'', include(router.urls)),
  24. path(r'api/', include('rest_framework.urls', namespace='rest_framework')),
  25. path('api-token-auth/', obtain_auth_token, name='api-token-auth')
  26.  
  27. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement