請問這兩種路由方式到底有什么不一樣,我在DRF中用方式一就可以拿到資料,方式二就直接路由出錯。StoreIndexView類是繼承RetrieveAPIView,路由中的pk值直接就可以查詢目標資料庫
# 方式一
re_path(r'^store/(?P<pk>\d+)/index/$', Store.StoreIndexView.as_view())
# 方式二
re_path(r'^store/(?P<pk>\d+)/$', include({
re_path(r'^index/$', Store.StoreIndexView.as_view())
}), None)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/283886.html
下一篇:如何避免重復取數 django
