示例:
from rest_framework import viewsets
我们调试GenericViewSet和ViewSet。
使用Router配置URL
get绑定到list:
from rest_framework.routers import DefaultRouter
router = DefaultRouter()
# 配置goods的list
router.register(r'goods', GoodsListViewSet)
urlpatterns = [
url(r'^$', include(router.urls), name="list"),
]
作用:list(get)和create(post)自动绑定。