- 接口设计规范 GET 127.0.0.1:8000/books/ # 获取所有数据 GET 127.0.0.1:8000/books/{id}/ # 获取单条数据 POST 127.0.0.1:8000/books/ # 添加一条数据 DELETE 127.0.0.1:8000/books/{id}/ # 删除一条数据 PUT 127.0.0.1:8000/books/{id}/ # 修改一条数据 class BookView(View): def get(self, request): pass def post(self, request): pass class BookSingleView(View): def get(self, request, nid): pass def delete(self, request, nid): pass def put(self, request, nid): pass - 返回数据规范 GET 127.0.0.1:8000/books/ # 获取所有数据 [{}, {}, {}, {}, {}] GET 127.0.0.1:8000/books/{id}/ # 获取单条数据 {} POST 127.0.0.1:8000/books/ # 添加一条数据 {}新增的数据 DELETE 127.0.0.1:8000/books/{id}/ # 删除一条数据 返回空 PUT 127.0.0.1:8000/books/{id}/ # 修改一条数据 {} - 错误消息规范 { "error": "error_message" }