1、修改路由管理urls.py文件
1)引用
from rest_framework.routers import DefaultRouter
2)路由注册
router = DefaultRouter()
router.register(r'hellotest', helloViewset, base_name="r'hellotest")
3)修改urlpatterns
新增:url(r'^', include(router.urls))
4)测试
使用postMan测试,返回信息,可以使用show出来的路由,继续其他信息查看。
HTTP 200 OKAllow:GET, HEAD, OPTIONSContent-Type:application/jsonVary:Accept{"eastcarstest": "http://127.0.0.1:8000/hellotest/"}
如果觉得《使用rest_framework的routers模块添加路由》对你有帮助,请点赞、收藏,并留下你的观点哦!