官方文档地址:https://www.django-rest-framework.org/tutorial/quickstart/#serializers
#url生成器生成四个url,就可以访问关于customer的五个方法 from rest_framework import routers router=routers.DefaultRouter() router.register("customer",views.CustomerView) urlpatterns = [ url(r'^', include(router.urls)), ]
在浏览器查看,url生成器为我们生成了四个url,可以使用customer.json调用,如http://127.0.0.1:8055/customer/9.json
: 可以访问第9条的json格式数据 ^ ^customer/$ [name='customer-list'] ^ ^customer.(?P<format>[a-z0-9]+)/?$ [name='customer-list'] ^ ^customer/(?P<pk>[^/.]+)/$ [name='customer-detail'] ^ ^customer/(?P<pk>[^/.]+).(?P<format>[a-z0-9]+)/?$ [name='customer-detail']