这是一个 DRF 中 urls.py
的写法示例,减少重复看文档的时间。
from django.contrib import admin
from django.urls import path, include
from rest_framework import routers
from main.views.book import BookViewSet, BookAuthorViewSet, BookPublisherViewSet
from main.views.user import SignupView
router = routers.DefaultRouter()
router.register('books', BookViewSet)
router.register('authors', BookAuthorViewSet)
router.register('publishers', BookPublisherViewSet)
urlpatterns = [
path('', include(router.urls)),
path('signup/', SignupView.as_view(), name='signup'),
path('admin/', admin.site.urls),
]