摘要:
两个url 共用一个视图 url url(r'^books/$', views.BookViewSet.as_view({"get":"list","post":"create"}),name="book_list"), #{"get":"list","post":"create" } 当参数传递给.as_view 里面会经过一系列的判断处理 来处理请求 url(r'^book... 阅读全文
摘要:
url: re_path('authors/$', views.AuthorView.as_view()), re_path('book/(?P\d+)/$', views.BookView.as_view()), #此阶段已经优化点了所有的retrun 返回数据 全部写到generics 父类里面去了 from rest_framework.mixins import CreateModel... 阅读全文
摘要:
url: re_path('authors/$', views.AuthorView.as_view()),re_path('authors/(\d+)/$', views.AuthorDetailView.as_view()), from rest_framework.mixins import CreateModelMixin as create #创建数据 f... 阅读全文