示例:
from rest_framework import viewsets
我們調(diào)試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)自動(dòng)綁定。