自动生成4个url
路由:
from rest_framework import routers
router = routers.DefaultRouter()
router.register(r'wrx',PagesView)
urlpatterns = [
re_path(r'^(?P<version>[v1|v2]+)/',include(router.urls)),
]
生成的URL
api/ ^(?P<version>[v1|v2]+)/ ^wrx/$ [name='userinfo-list']
api/ ^(?P<version>[v1|v2]+)/ ^wrx.(?P<format>[a-z0-9]+)/?$ [name='userinfo-list']
api/ ^(?P<version>[v1|v2]+)/ ^wrx/(?P<pk>[^/.]+)/$ [name='userinfo-detail']
api/ ^(?P<version>[v1|v2]+)/ ^wrx/(?P<pk>[^/.]+).(?P<format>[a-z0-9]+)/?$ [name='userinfo-detail']