Django Rest Framework之路由
一:路由组件
REST framework提供了两个router:SimpleRouter与DefaultRouter
二:SimpleRouter
三:DefaultRouter
DefaultRouter继承自SimpleRouter
from rest_framework.routers import DefaultRouter
router = DefaultRouter()
router.register(r'^book', views.BookModelView, basename='book')
urlpatterns = [
re_path(r'^', include(router.urls)),
]