{"id":439287,"date":"2021-04-15T16:52:56","date_gmt":"2021-04-15T08:52:56","guid":{"rendered":"http:\/\/4563.org\/?p=439287"},"modified":"2021-04-15T16:52:56","modified_gmt":"2021-04-15T08:52:56","slug":"%e6%83%b3%e9%97%ae%e9%97%ae%e5%a4%a7%e5%ae%b6%e5%9c%a8-djangodrf-%e7%9a%84%e5%bc%80%e5%8f%91%e6%a1%86%e6%9e%b6%e4%b8%8b%ef%bc%8c%e6%b6%89%e5%8f%8a%e5%a4%9a%e8%a1%a8%e7%9a%84%e6%95%b0%e6%8d%ae","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=439287","title":{"rendered":"\u60f3\u95ee\u95ee\u5927\u5bb6\u5728 Django+DRF \u7684\u5f00\u53d1\u6846\u67b6\u4e0b\uff0c\u6d89\u53ca\u591a\u8868\u7684\u6570\u636e\u5e93\u76f8\u5173\u64cd\u4f5c\u5728\u54ea\u5c42\u505a\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u60f3\u95ee\u95ee\u5927\u5bb6\u5728 Django+DRF \u7684\u5f00\u53d1\u6846\u67b6\u4e0b\uff0c\u6d89\u53ca\u591a\u8868\u7684\u6570\u636e\u5e93\u76f8\u5173\u64cd\u4f5c\u5728\u54ea\u5c42\u505a\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zhoudaiyu <\/span>  <span><i><\/i> 0<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u5f53 ModelViewSet \u81ea\u5e26\u7684\u65b0\u589e\u3001\u4fee\u6539\u3001\u5220\u9664\u65b9\u6cd5\u4e0d\u80fd\u6ee1\u8db3\u7ee7\u627f ModelViewSet \u7684\u89c6\u56fe\u7684\u9700\u6c42\u65f6\uff0c\u4f8b\u5982\u65b0\u589e\u3001\u66f4\u65b0\u6d89\u53ca\u5230\u591a\u4e2a\u8868\u65f6\u3002\u8fd9\u6837\u53ef\u4ee5\u9009\u62e9\u5728\u89c6\u56fe\uff08 views \uff09\u3001\u5e8f\u5217\u5316\u5668\uff08 serializers \uff09\u6216\u8005\u6a21\u578b\uff08 models \uff09\u91cc\u91cd\u5199\u8fd9\u4e9b\u65b9\u6cd5\u3002\u73b0\u5728\u6211\u4eec\u516c\u53f8\u7684\u73b0\u72b6\u662f\u5728\u54ea\u5c42\u91cd\u5199\u7684\u90fd\u6709\uff0c\u6ca1\u6709\u5565\u89c4\u8303\u3002\u60f3\u95ee\u95ee\u8fd9\u4e2a\u4e1c\u897f\u6709\u4ec0\u4e48\u6700\u4f73\u5b9e\u8df5\u5417\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>4<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5754309\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : IurNusRay <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u4e00\u822c\u662f\u5728\u5e8f\u5217\u5316\u5668\u7684 create\/update \u65b9\u6cd5\u4e2d\u6765\u5199\uff0c\u5728\u89c6\u56fe\u4e2d\u5199\u9700\u8981\u5199\u4e00\u4e9b\u91cd\u590d\u4ee3\u7801\uff0c\u5728\u6a21\u578b\u4e2d\u5199\u53ef\u80fd\u9700\u8981\u5c06\u8bf7\u6c42\u4e0a\u4e0b\u6587\u4f20\u5165\uff0c\u6240\u4ee5\u611f\u89c9\u5728\u5e8f\u5217\u5316\u5668\u4e2d\u5199\u6bd4\u8f83\u7b80\u6d01                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5754310\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Alexf4 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             [best-pratices]( https:\/\/lincolnloop.com\/django-best-practices\/)<br \/>\u6211\u4e00\u822c\u4e1a\u52a1\u903b\u8f91\u90fd\u662f\u653e model \u5c42\uff0cview \u5c42\u5927\u591a\u6570\u505a\u5224\u65ad\u4e4b\u7c7b\u7684\u3002<br \/>\u4f46\u662f\u7559\u610f\u5230\u9898\u4e3b\u53ef\u80fd\u66f4\u591a\u7684\u95ee\u9898\u662f\u516c\u53f8\u56e2\u961f\u5185\u90e8\u7684\u4e0d\u7edf\u4e00\u5427\u3002\u3002\u8bd5\u8bd5\u4e3b\u52a8 push \u4e0b\u4ee3\u7801\u89c4\u8303\u7edf\u4e00\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5754311\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zxzflower <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u4eec\u662f\u5168\u90e8\u653e\u5728\u4e00\u4e2a handler \u5c42\u53bb\u505a view \u53ea\u505a http \u76f8\u5173\u7684\u64cd\u4f5c                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5754312\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dayeye2006199 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u4ee5\u653e\u5728 serializer \u91cc\u9762 override create \u548c update \u65b9\u6cd5\u3002<br \/>\u6216\u8005\u653e\u5728 model \u5c42\uff0coverride model manager \u7684\u7c7b\u578b\u3002<\/p>\n<p>\u4e24\u4e2a\u90fd\u53ef\u4ee5\uff0c\u7b2c\u4e8c\u4e2a\u65b9\u6848\u4ee3\u7801\u66f4\u5e72\u51c0\u4e00\u4e9b\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u60f3\u95ee\u95ee\u5927\u5bb6\u5728 Django+DRF&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/439287"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=439287"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/439287\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=439287"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=439287"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=439287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}