标签:pac clu frame 配置路由 rom 认证 pat 路由 rest
user/urls.py
ModelViewSet注册路由三部曲
from django.urls import include, path
from user import views
from rest_framework.routers import SimpleRouter, DefaultRouter
# 自动生成路由方法, 必须使用视图集 # router = SimpleRouter() # 没有根路由 /user/ 无法识别
router = DefaultRouter() # 1.有根路由
router.register(r‘user‘, views.UserViewSet) # 2.配置路由
urlpatterns = [
path(‘index/‘, views.index),
path(‘api-auth/‘, include(‘rest_framework.urls‘, namespace=‘rest_framework‘)) # 认证地址
]
urlpatterns += router.urls # 3.模块地址
标签:pac clu frame 配置路由 rom 认证 pat 路由 rest
原文地址:https://www.cnblogs.com/aa1bb2/p/13887644.html