{"id":159240,"date":"2020-09-23T15:05:32","date_gmt":"2020-09-23T07:05:32","guid":{"rendered":"http:\/\/4563.org\/?p=159240"},"modified":"2020-09-23T15:05:32","modified_gmt":"2020-09-23T07:05:32","slug":"%e7%94%a8-django-%e5%86%99-web-%e5%86%99%e7%9a%84%e6%97%a0%e6%af%94%e7%97%9b%e8%8b%a6%ef%bc%8c%e6%98%af%e6%88%91%e7%9a%84%e9%97%ae%e9%a2%98%e5%90%97%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=159240","title":{"rendered":"\u7528 Django \u5199 web \u5199\u7684\u65e0\u6bd4\u75db\u82e6\uff0c\u662f\u6211\u7684\u95ee\u9898\u5417\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u7528 Django \u5199 web \u5199\u7684\u65e0\u6bd4\u75db\u82e6\uff0c\u662f\u6211\u7684\u95ee\u9898\u5417\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : subpo <\/span>  <span><i><\/i> 0<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\">                        \u6700\u8fd1\u4ece Ruby on Rails \u5207\u6362\u5230 Python on Django \u3002\u624d\u4e0a\u624b\u5199\u4e86\u51e0\u5929\uff0c\u53ef\u80fd\u5bf9 Django \u7406\u89e3\u4e0d\u6df1\u523b\uff0c\u4f46\u662f\u8fd9\u51e0\u5929\u771f\u7684\u628a\u6211\u6076\u5fc3\u7684\u60f3\u5410\uff0c\u8fd9\u662f\u6211\u7684\u95ee\u9898\u5417\uff1f\u8fd8\u662f\u7ee7\u7eed\u5199\u4e0b\u53bb\u5c31\u80fd\u53d1\u73b0\u8fd9\u4e2a\u5c06\u8fd1 20 \u5e74\u7684\u6846\u67b6\u7684\u4f18\u79c0\u70b9\uff1f<\/p>\n<p>Python \u867d\u7136\u5bf9\u6211\u6765\u8bf4\u8fd8\u6709\u4e00\u70b9\u70b9\u5c0f\u522b\u626d\u7684\u5730\u65b9\uff08\u6bd4\u5982\u660e\u660e\u662f\u4e00\u5207\u7686\u5bf9\u8c61\uff0c\u5374\u4f7f\u7528 len(obj)\u800c\u4e0d\u662f obj.len()\uff09\uff0c\u603b\u4f53\u6765\u8bf4\u5199\u8d77\u6765\u8fd8\u662f\u6bd4\u8f83\u723d\uff0c\u8bed\u6cd5\u6bd4\u8f83\u7b80\u5355\uff0c\u8c03\u8bd5\u5de5\u5177\u94fe\u5b8c\u5584\uff0c\u7f51\u4e0a\u80fd\u627e\u5230\u7684\u8d44\u6599\u4e5f\u591a\u3002<\/p>\n<p>\u4f46\u662f Django \u7b80\u76f4\u8ba9\u6211\u75db\u82e6\u65e0\u6bd4\u3002<\/p>\n<p>\u6309\u7167\u5b98\u65b9\u6587\u6863\uff0crouter \u5c42\u65e0\u6cd5\u5b9a\u4e49\u8bf7\u6c42\u7c7b\u578b\uff0c\u8981\u5728 ViewController \u91cc\u9762\u5199 if request.method == &#8220;POST&#8221; \u3002<br \/>\u7578\u5f62\u7684\u6a21\u677f\u7cfb\u7edf\uff0c\u65e0\u6cd5\u5728\u6a21\u677f\u5c42\u5199\u811a\u672c\uff0c\u8fd9\u70b9\u6211\u53ef\u4ee5\u7406\u89e3\u662f\u67b6\u6784\u7684\u8bbe\u8ba1\u8003\u8651\u5230\u4e0d\u60f3\u5728\u6a21\u677f\u5c42\u5f15\u5165\u903b\u8f91\uff0c\u4f46\u653e\u7740 python \u8fd9\u4e48\u6709\u8868\u73b0\u529b\u7684\u8bed\u8a00\u4e0d\u7528\uff0c\u786c\u662f\u53d1\u660e\u4e86\u4e00\u4e2a\u65b0\u7684\u6a21\u677f\u8bed\u6cd5\uff0c\u5b9e\u5728\u662f\u7406\u89e3\u4e0d\u80fd\u3002<\/p>\n<p>\u7ec6\u8282\u7684\u95ee\u9898\u66f4\u52a0\u6570\u4e0d\u80dc\u6570<br \/>\u6bd4\u5982\u5199\u4e00\u4e9b\u590d\u6742\u7684 View\uff0c\u9700\u8981\u628a\u540c\u4e00\u4e2a\u8d44\u6e90\u7684 POST \u548c GET \u65b9\u6cd5\u62c6\u5f00\u5199<br \/>post \/api\/resources create_resource_view<br \/>get \/api\/resources list_resource_view<br \/>\u5c45\u7136\u53d1\u73b0 Django \u7684 router \u4e0d\u652f\u6301\u628a\u8fd9\u79cd\u7ea6\u5b9a\u4fd7\u6210\u7684 RESTful api \u5bfc\u5411\u4e0d\u540c\u7684\u6587\u4ef6<\/p>\n<p>\u6a21\u677f\u5c42\u4e5f\u5404\u79cd\u96be\u53d7\uff0cAPI \u63a5\u53d7\u5230 string \u683c\u5f0f\u7684 date \u53c2\u6570\uff0c\u9700\u8981\u8f6c\u6210 date \u683c\u5f0f\u5b58\u5165\u6570\u636e\u5e93\uff0c\u8fd9\u4e48\u4e00\u4e2a\u4efb\u4f55\u4e00\u4e2a APP \u90fd\u4f1a\u9047\u5230\u65e0\u6570\u6b21\u7684\u903b\u8f91\uff0c\u90fd\u9700\u8981 hard coding \u6216\u4e09\u884c\u4ee5\u4e0a\u7684\u4ee3\u7801\u6765\u5904\u7406<\/p>\n<p>API \u53c2\u6570\u9a8c\u8bc1\u4e5f\u5f88\u7cdf\u7cd5\uff0cORM \u4e5f\u5f88\u7cdf\u7cd5\uff0c\u4e00\u5410\u69fd\u90fd\u505c\u4e0d\u4e0b\u6765\uff0c\u54ea\u91cc\u54ea\u91cc\u90fd\u5f88\u7cdf\u7cd5      <\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>30<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3426076\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wander639 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             view \u7684\u8bdd\u53ef\u4ee5\u8003\u8651\u4e0b cbv<br \/>\u6a21\u677f\u7684\u8bdd\u4e0d\u77e5\u9053\u80fd\u4e0d\u80fd\u81ea\u5df1\u6362\u6210 mako<br \/>\u4e2a\u4eba\u89c9\u5f97 django \u7684 orm \u8fd8\u662f\u633a\u597d\u7528\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426077\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Rxianbei <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u554a\uff0c\u5bf9\u5440\uff0c\u8981\u5728 view \u5c42\u5b9a\u4e49\u8bf7\u6c42\u65b9\u5f0f\u5b9e\u5728\u662f\u628a\u6211\u770b\u5f97\u4e00\u6123\u4e00\u6123\uff0c\u8fd9\u4e5f\u592a\u4e0d\u4f18\u96c5\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426078\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : cyssxt <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u719f\u80fd\u751f\u5de7                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426079\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : youngce <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             1. obj.__len__()\u662f len(obj)\u9762\u5411\u5bf9\u8c61\u7684\u5199\u6cd5\uff0c\u4e0d\u4e3b\u52a8\u5b9a\u4e49\u4e3a obj.len \uff08\uff09\u662f\u8003\u8651\u5230\u5f88\u591a\u4eba\u4e5f\u9700\u8981\u5bf9\u8fd9\u79cd\u4e1c\u897f\u81ea\u5b9a\u4e49<br \/>2.django \u662f\u4f60\u7684\u7406\u89e3\u8fd8\u4e0d\u591f\u7684\uff0c\u4f60\u5217\u4e3e\u7684\u90a3\u4e9b\u95ee\u9898\uff0cdjango \u90fd\u6709\u5b8c\u5584\u7684\u9ad8\u7ea7\u7684\u5904\u7406\u529e\u6cd5\uff0c\u4f46\u662f\u4f60\u5982\u679c\u53ea\u770b\u4e86\u4e86\u4e00\u4e2a\u5165\u95e8\u6559\u7a0b\uff0c\u53ef\u80fd\u662f\u8fd8\u6ca1\u63a5\u89e6\u5230\u8fd9\u4e9b\u3002django \u5c5e\u4e8e\u90a3\u79cd\u9700\u8981\u4e00\u6bb5\u65f6\u95f4\u4e0a\u624b\u7684\u6846\u67b6\uff0c\u4e0d\u8981\u6307\u671b\u4e00\u4e0a\u624b\u5c31\u638c\u63e1\u6240\u6709 django \u7279\u6027\uff0c\u5982\u679c\u6ca1\u6709\u8010\u5fc3\uff0c\u8bf7\u4f7f\u7528 flask \u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426080\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : youngce <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             CVB \u662f\u4e0d\u8981\u6574\u8fd9\u4e9b view \u5c42\u5b9a\u4e49\u7684\uff0c\u8def\u7531\u4e5f\u662f\u5b8c\u5168\u7684 rest \u98ce\u683c\uff0c\u6b63\u7ecf\u5199 api\uff0c\u4e5f\u90fd\u7528 drf \u7684\uff0c\u4e0d\u8981\u88ab\u4e00\u4e9b\u6c34\u8d27\u6559\u7a0b\u8bef\u5bfc\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426081\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : subpo <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @youngce #5 rest framework \u6709\u5728\u7528\uff0c\u6211\u4e5f\u60f3\u5410\u69fd\u6765\u7740\uff0cserializer \u5c31\u6211\u4e2a\u4eba\u7684\u611f\u89c9\uff0c\u4e00\u822c\u662f\u683c\u5f0f\u5316\u8f93\u51fa\u7684\u4e1c\u897f\uff0c\u4f46\u662f rest framework \u628a serializer \u540c\u65f6\u4f5c\u7528\u4e8e\u53c2\u6570\u8f93\u5165\uff0c\u9a8c\u8bc1\uff0c\u5b58\u50a8\u548c\u683c\u5f0f\u5316\u8f93\u51fa\uff0c\u4e00\u4e9b\u5e38\u7528\u7684\u529f\u80fd\uff08\u81ea\u5b9a\u4e49\u8f93\u5165\u9a8c\u8bc1\uff0c\u8f93\u51fa\u9644\u4e0a\u4e00\u4e9b\u81ea\u5b9a\u4e49\u5b57\u6bb5\uff09\u4e5f\u6ca1\u80fd\u7b80\u5355\u7684\u63d0\u4f9b\uff0c\u90fd\u9700\u8981\u8fdb\u884c\u4e00\u4e9b\u6709\u4e9b\u5947\u602a\u7684\u64cd\u4f5c\u3002<\/p>\n<p>\u4e0d\u8fc7\u6709\u4f60\u8fd9\u4e48\u8bf4\u6211\u5c31\u653e\u5fc3\u591a\u4e86&#8230;\u8f83\u957f\u65f6\u95f4\u91cc\u4e0d\u5f97\u4e0d\u63a5\u89e6 Django \u7684\u8bdd\uff0c\u5b81\u613f\u662f\u6211\u81ea\u5df1\u83dc                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426082\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Philippa <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             Django \u8d77\u624b\u633a\u590d\u6742\u7684\uff0c\u800c\u4e14\u8bbe\u8ba1\u5f97\u5f88\u7e41\u6742\uff0c\u5f88\u591a\u9b54\u6cd5\uff0c\u6211\u4e00\u5f00\u59cb\u4e5f\u5f88\u96be\u9002\u5e94\u3002\u6211\u540e\u6765\u627e\u5230\u4e00\u4e2a\u5165\u95e8 tutorial \u53bb\u5199\u4e2a\u5c0f demo \u624d\u6162\u6162\u5165\u95e8\u3002<\/p>\n<p>\u4e00\u822c\u4f7f\u7528 rest_framework + Django + \u4e00\u70b9\u6700\u4f73\u5b9e\u8df5\u3002\u7528 ModelView \u548c Model Serializer \u90a3\u79cd\u9ad8\u5ea6\u62bd\u8c61\u5f97\u8bed\u6cd5\u6765\u5199\uff0c\u5f00\u53d1\u901f\u5ea6\u975e\u5e38\u975e\u5e38\u5feb\u7684\uff0c\u800c\u4e14\u5b83\u751f\u6001\u5f88\u597d\uff0c\u9664\u4e86\u57fa\u7840\u529f\u80fd\uff0c\u8fde aws \u7b49\u5e73\u53f0\u7ed1\u5b9a\u7684 libaries \u4e5f\u4e00\u5927\u5806\uff0c\u5982\u679c\u4f60\u60f3\u6700\u5927\u5316\u81ea\u5df1\u7684\u5f00\u53d1\u901f\u5ea6\uff0cDjango \u4e00\u5b9a\u662f Python \u6700\u597d\u7684\u9009\u62e9\uff0c\u5373\u4f7f\u548c\u5176\u4ed6\u8bed\u8a00\u7684 Web \u6bd4\u8f83\u5982 PHP \u548c Ruby \u4e5f\u6beb\u4e0d\u900a\u8272\u3002<\/p>\n<p>\u6211\u7528 Django \u5199 web \u5927\u90e8\u5206\u65f6\u95f4\u5176\u5b9e\u90fd\u662f\u9075\u7167 TDD \u5199 unittest \u7684\uff0c\u56e0\u4e3a\u4e00\u822c\u5e38\u89c1\u7684 API \u5f00\u53d1\uff0c\u5199 view\/model\/serializer \u7b49\u90fd\u6ca1\u591a\u5c11\u884c\u4ee3\u7801\uff0c\u5927\u90e8\u5206\u4ee3\u7801\u90fd\u662f unittest \u3002\u4f46\u8fd9\u79cd\u9ad8\u5ea6\u62bd\u8c61\u7684\u5199\u6cd5\u5f88\u5bb9\u6613\u51fa\u9519\uff0c\u591a\u4e00\u884c\uff0c\u5c11\u4e00\u4e2a\u65b9\u6cd5\u53ef\u80fd\u76f8\u5dee\u975e\u5e38\u5927\uff0c\u4e0d\u5199 unittest \u6765 debug \u662f\u975e\u5e38\u56f0\u96be\u7684\u3002<\/p>\n<p>\u5efa\u8bae\u591a\u82b1\u4e00\u5468\u5b9e\u8df5\u7ee7\u7eed\u7814\u7a76\u4e00\u4e0b\uff0c\u6211\u5f53\u65f6\u521a\u5f00\u59cb\u4e5f\u89c9\u5f97\u5f88\u75db\u82e6= =\uff0c\u600e\u4e48\u8bbe\u8ba1\u90a3\u4e48\u810f\uff0c\u4e3a\u4ec0\u4e48\u8981\u7528\u5b57\u7b26\u4e32\u800c\u4e0d\u662f\u7c7b\uff0c\u4e3a\u4ec0\u4e48\u8981\u53bb override \u90a3\u4e48\u591a\u65b9\u6cd5\u6765\u5b9e\u73b0 api \u7b49\u7b49\uff0c\u4e2d\u9014\u8fd8\u4e00\u5ea6\u653e\u5f03\u53bb\u5199 flask\/echo\uff0c\u4f46\u6700\u7ec8\u5c1d\u8bd5\u4e0b\u6765\u53d1\u73b0\u8fd9\u503c\u5f97\uff0c\u5f00\u53d1\u6548\u7387\u975e\u5e38\u975e\u5e38\u9ad8\uff0c\u73b0\u5728\u6211\u4e2a\u4eba\u5f00\u53d1\u90fd\u662f Django + React \u3002\u4e2a\u4eba\u7684 Nodejs \u7684 Nestjs \u8fd8\u662f Expressjs \u7684\u5f00\u53d1\u6548\u7387\u548c Django \u8fd8\u662f\u5dee\u4e00\u4e2a\u7b49\u7ea7\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426083\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : subpo <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @subpo #6 \u6211\u8868\u8fbe\u7684\u4e0d\u662f\u5f88\u6e05\u695a\u3002\u91cd\u65b0\u8bf4\u4e00\u4e0b<\/p>\n<p>\u6bd4\u65b9\u8bf4\u4e00\u4e2a api \u7684 create \u90e8\u5206\u7684\u5e38\u89c1\u64cd\u4f5c:<br \/>1. \u9a8c\u8bc1\u4f20\u8f93\u8fdb\u6765\u7684\u6570\u636e\u7684\u5408\u6cd5\u6027\uff0c\u5305\u62ec\u6570\u636e\u683c\u5f0f\u8f6c\u6362\uff0c\u9a8c\u8bc1\u7b49<br \/>2. \u8fdb\u884c\u4e00\u4e9b\u4e1a\u52a1\u903b\u8f91\u540e\u5b58\u5165\u6570\u636e\u5e93<br \/>3. \u8fd4\u56de\u5b58\u5165\u7684\u5b57\u6bb5\u548c\u4e00\u4e9b\u81ea\u5b9a\u4e49\u5b57\u6bb5<\/p>\n<p>\u8fd9\u4e2a\u5e38\u89c1\u7684\u64cd\u4f5c\u7528 drf \u600e\u4e48\u90fd\u8d70\u4e0d\u987a\u3002\u64cd\u4f5c 1 \u7684 serializer\uff0c\u64cd\u4f5c 2 \u7684 model\uff0c\u64cd\u4f5c 3 \u7684\u8fd4\u56de serializer \u51e0\u4e4e\u662f\u540c\u4e00\u6837\u4e1c\u897f\uff0c\u4f46\u662f\u53c8\u6709\u4e00\u4e9b\u7ec6\u8282\u4e0d\u540c\uff0c\u5b9e\u73b0\u8d77\u6765\u5f88\u522b\u626d\uff0c\u4e0d\u987a\u3002<\/p>\n<p>\u5e76\u4e14\u4e2a\u4eba\u8ba4\u4e3a djr \u7684 Restful \u8bbe\u8ba1\u7684\u4e0d\u592a\u597d\uff0c\u8bda\u7136\u505a\u4e00\u4e2a\u6807\u51c6\u7684 CURD \u64cd\u4f5c\u7528 Viewset \u975e\u5e38\u65b9\u4fbf\u7528\u4e0d\u4e86\u51e0\u884c\u4ee3\u7801\uff0c\u4f46\u662f\u771f\u6b63\u653e\u5230\u4e1a\u52a1\u903b\u8f91\u91cc\uff0c\u53c8\u6709\u591a\u5c11\u6807\u51c6\u53c8\u65e0\u6269\u5c55\u903b\u8f91\u7684 CURD \u5462\uff1f\u8fd9\u65f6\uff0cdjr \u9700\u8981\u7528\u4e0d\u540c\u4e8e Viewset \u7684\u53e6\u5916\u4e00\u5957\u903b\u8f91\u6765\u5904\u7406\u8fd9\u90e8\u5206\u4e1a\u52a1\u903b\u8f91\uff0c\u663e\u5f97\u975e\u5e38\u8106\u5f31\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426084\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : iConnect <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5982\u679c\u719f\u6089\u5de5\u5382\u6a21\u5f0f\uff0c\u6362 flask \u5427\uff0cdjango \u7684\u8def\u7531\u8bbe\u8ba1\u4e0d\u5982 flask \u6765\u7684\u7b80\u6d01\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426085\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dcalsky <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @subpo DRF \u5c31\u662f\u5f00\u53d1\u5c0f\u529f\u80fd\u5feb\uff0c\u4f60\u8981\u505a\u7ec6\u7684\u8bdd\uff0c\u90a3\u5c31\u5f97\u597d\u597d\u770b\u770b\u5404\u4e2a serializer \u4ee5\u53ca serializer relation \u3002\u5f88\u591a\u903b\u8f91\u8981\u5728 serialization \u7684 create validate save \u91cc\u9762\u505a\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426086\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : comwrg <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u540c\u6837\u7684\u611f\u89c9\u2026                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426087\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : comwrg <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8981\u4e0d\u662f python \u8f6e\u5b50\u591a\uff0c\u5bf9\u4e8e\u4e2a\u4eba\u5f00\u53d1\u8005\u6765\u8bf4\u6211\u8fd8\u662f\u9009\u62e9 rails\uff0c\u800c\u4e0d\u662f python \u7684 web \u6846\u67b6                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426088\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : oahebky <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u662f\u4f60\u7684\u95ee\u9898\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426089\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zachlhb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             cbv \u662f\u53ef\u4ee5\u5b9a\u4e49\u8bf7\u6c42\u7c7b\u578b\uff0cclass \u91cc\u65b9\u6cd5\u540d\u5b9a\u4e49\u6210 method \u5c31\u884c\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426090\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zachlhb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5982\u679c\u5199\u63a5\u53e3\u53ef\u4ee5\u7528 drf \u7684 viewset\uff0c\u7136\u540e\u5728\u8def\u7531\u7684 as_view \u91cc\u9762\u5b9a\u4e49\u8bf7\u6c42\u7684 method \u548c\u5bf9\u5e94\u7684\u65b9\u6cd5                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426091\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : MintZX <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             ruby on rails \u5f00\u53d1\u7ed9\u4f60\u70b9\u4e2a\u8d5e\u3002\u3002\u3002<\/p>\n<p>\u786e\u5b9e\u4e0d\u559c\u6b22 django \u7684\u5199\u6cd5\uff0c\u4f46\u662f\u65b0\u516c\u53f8\u7684\u6280\u672f\u6808\u5c31\u662f django \u548c flask\uff0c\u53ea\u80fd\u88ab\u8feb\u7528\u4e86                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426092\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ericls <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0d\u5c31\u662f\u4e2a wsgi                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426093\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : steptodream <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u662f\u4e8c\u6d41\u641e IT \u7684 \u88ab\u8feb\u5f00\u53d1\u5185\u90e8 web \u9002\u5e94\u5c1d\u8bd5\u4e86\u4e00\u5708 \u53d1\u73b0\u5bf9\u4e8e\u6211\u6765\u8bf4 django \u6700\u5bb9\u7406\u89e3                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426094\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wellsc <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7528 go \u8bd5\u8bd5(\u624b\u52a8\u72d7\u5934                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426095\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : 0312birdzhang <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             +10086 \u554a\uff0c\u5199\u7684\u592a\u75db\u82e6\u4e86\uff0c\u4e8e\u662f\u6211\u7528 java \u4e86\uff08\u6ed1\u7a3d                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426096\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : BenX <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e00\u5207\u539f\u56e0\u5728\u4e8e\u4f60\u4ece ror \u8f6c\u51fa\u6765\u7684\uff0c\u88ab ror \u4f3a\u5019\u8fc7\uff0c\u5176\u5b83\u90fd\u4e0d\u9999\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426097\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wangkun025 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u88ab rails \u60ef\u574f\u4e86\u3002<br \/>\u6700\u8fd1\u770b spring boot\uff0c\u8fde router \u90fd\u6ca1\u6709\u3002\u76f4\u63a5\u5728 controller \u91cc\u5199 mapping\uff0c\u5c82\u4e0d\u662f\u66f4\u52a0\u90c1\u95f7\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426098\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Jammar <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7528 drf<br \/>router \u76f4\u63a5\u6307\u5411\u51fd\u6570\u6216\u8005\u7c7b(\u5b9e\u73b0 as_view()\u65b9\u6cd5\u7684)<br \/>view \u5c42\u5b9a\u4e49 method,\u6709\u5f88\u591a\u79cd\u653e\u6211,\u6211\u5e38\u7528\u5728\u7c7b\u4e0b\u9762 def get<br \/>string \u8f6c date,\u6211\u6ca1\u8bb0\u9519\u7684\u8bdd\u53ef\u4ee5\u76f4\u63a5\u5e8f\u5217\u5316,\u6216\u8005\u4f7f\u7528\u4e00\u4e9b\u6a21\u5757\u4e00\u884c\u4ee3\u7801\u7684\u4e8b\u60c5,\u6bd4\u5982 datetime<br \/>api \u53c2\u6570\u9a8c\u8bc1\u76f4\u63a5\u4f7f\u7528 serializer.is_valid()\u6ca1\u6709\u62a5\u9519.data \u83b7\u53d6\u6570\u636e<br \/>orm \u662f\u9762\u5411\u5bf9\u8c61\u7684\u5f62\u5f0f user=User(),user.name=xxx,user.sava()<br \/>\u5bf9\u4e8e\u4e00\u4e2a\u5e38\u89c1\u7684 create \u64cd\u4f5c,\u5148\u5199 modelserializer,\u518d\u89c6\u56fe\u5c42\u9a8c\u8bc1\u53d6\u6570\u636e,\u53ef\u4ee5\u770b\u4e00\u4e0b drf \u7684 CreateAPIView                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426099\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Akkuman <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u628a drf \u7684\u6587\u6863\u770b\u5b8c\uff0c\u7136\u540e\u8fb9\u505a\u8fb9\u770b\u6e90\u7801\uff0c\u5176\u5b9e\u4f60\u4f1a\u53d1\u73b0\u5404\u4e2a\u5730\u65b9\u90fd\u6709\u94a9\u5b50\uff0c\u53ef\u63a7\u6027\u633a\u5f3a\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426100\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : 37Y37 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u4e0d\u7ba1\uff0c\u53cd\u6b63\u6211\u7528\u8d77\u6765\u8d3c\u9999\uff0c\u54c8\u54c8                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426101\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : nonduality <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8bf4\u8d77\u6765\uff0c\u4f60\u7684\u62b1\u6028\u6765\u81ea\u4e24\u70b9\uff1a1 \u3001\u7f3a\u5c11\u5f00\u653e\u601d\u7ef4\uff0c\u5e26\u7740 ROR \u7684\u56fa\u6709\u4e60\u60ef\uff0c\u8ba4\u4e3a ROR \u7684\u505a\u6cd5\u624d\u662f\u552f\u4e00\u6b63\u786e\uff1b 2 \u3001\u5bf9 Django \u5b66\u827a\u4e0d\u7cbe\uff0cDjango \u4f5c\u4e3a\u5e7f\u6cdb\u4f7f\u7528\u7684\u6846\u67b6\uff0c\u5982\u679c\u5927\u5bb6\u90fd\u662f\u50cf\u4f60\u90a3\u6837\u5728\u5fcd\u53d7\u5404\u79cd\u7f3a\u9677\uff0c\u662f\u4e0d\u53ef\u80fd\u8d70\u5230\u73b0\u5728\u7684\u3002<\/p>\n<p>\u6211\u4ece\u6765\u4e0d\u559c\u6b22\u57fa\u4e8e\u51fd\u6570\u6765\u5904\u7406\u8bf7\u6c42\uff0c\u559c\u6b22\u7528 class-based view\uff0c\u5b81\u53ef\u76f4\u63a5\u7ee7\u627f GenericView \u6765\u5199\uff0c\u540c\u4e00\u4e2a\u7c7b\u4e0b\u5b9a\u4e49\u4e00\u4e2a get \u548c\u4e00\u4e2a post \u65b9\u6cd5\uff0c\u7136\u540e as_view()\u7ed1\u5b9a\u5230\u540c\u4e00\u4e2a url\uff0c\u6839\u672c\u4e0d\u4f1a\u6709\u4f60\u8bf4\u7684\u95ee\u9898\u3002<\/p>\n<p>\u81f3\u4e8e\u6a21\u677f\uff0c\u5c5e\u4e8e\u89c1\u4ec1\u89c1\u667a\uff0c\u5982\u679c\u5141\u8bb8\u6a21\u677f\u5199\u5f88\u591a\u4ee3\u7801\uff0c\u90a3\u5c31\u8fdd\u80cc\u4e86\u903b\u8f91\u548c\u8868\u73b0\u5206\u79bb\u7684\u539f\u5219\uff0c\u9f13\u52b1\u7528\u6237\u5c06\u66f4\u591a\u7684\u903b\u8f91\u6254\u5230\u6a21\u677f\u91cc\u3002<\/p>\n<p>API \u7684\u95ee\u9898\uff0c\u7528 DRF \u3002<\/p>\n<p>Django ORM \u6211\u8ba4\u4e3a\u5f88\u597d\u5f88\u4f18\u96c5\uff0c\u5c3d\u7ba1\u6211\u4e5f\u53ef\u4ee5\u63a5\u53d7 SqlAlchemy \u7684\u5f62\u5f0f\uff08 Flask \u7528\u7684\u662f\u4fee\u6539\u8fc7\u7684\uff0c\u8981\u4e0d\u66f4\u96be\u7528\uff09\uff0c\u4f46\u50cf Pony \u4e4b\u7c7b\u641e\u7684\u9ed1\u9b54\u6cd5\uff0clambda \u6ee1\u5929\u98de\uff0c\u624d\u53eb\u7cdf\u7cd5\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426102\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : libracloud <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7528 rails \u540e\uff0c\u7528\u5565\u90fd\u4e0d\u723d                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426103\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : linvaux <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7528 fastapi                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426104\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Mark24 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f53\u9a8c\u8fc7 rails\uff0c\u6211\u9009 Ruby On Rails<\/p>\n<p>Python \u786e\u5b9e\u4f18\u79c0<\/p>\n<p>\u4f46\u662f Ruby \u4f3c\u4e4e\u66f4\u80dc\u4e00\u7b79~                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3426105\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xulolololololo <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u4ee5\u524d\u4e5f\u662f\u7528 django \u7684\uff0c\u4f46\u662f\u6211\u4eec\u90fd\u662f\u81ea\u5df1\u5b9a\u5236\u5316\u81ea\u5df1\u516c\u53f8\u7684\u4e1a\u52a1 view\uff0c\u6240\u4ee5\u4e0d\u6d89\u53ca django \u592a\u591a\u5947\u5947\u602a\u602a\u7684\u4e1c\u897f\u3002\u7136\u540e\u65b0\u516c\u53f8\u6362\u6210 sanic\uff0c\u4e5f\u662f\u5b9a\u5236\u4e86\u4e00\u4e0b\u5c31\u5199\u4e86\uff0c\u8fd9 web \u5f00\u53d1\u5c31\u662f\u8fd9\u4e48\u56de\u4e8b\uff0c\u6846\u67b6\u968f\u4fbf\u6362\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u7528 Django \u5199 web \u5199\u7684&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\/159240"}],"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=159240"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/159240\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=159240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=159240"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=159240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}