{"id":188462,"date":"2020-11-08T23:28:15","date_gmt":"2020-11-08T15:28:15","guid":{"rendered":"http:\/\/4563.org\/?p=188462"},"modified":"2020-11-08T23:28:15","modified_gmt":"2020-11-08T15:28:15","slug":"%e5%8f%af%e4%bb%a5%e5%9c%a8-views-%e4%b8%ad%e9%87%8d%e8%bd%bd-django-%e4%b9%88%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=188462","title":{"rendered":"\u53ef\u4ee5\u5728 views \u4e2d\u91cd\u8f7d django \u4e48\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u53ef\u4ee5\u5728 views \u4e2d\u91cd\u8f7d django \u4e48\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Eyon <\/span>  <span><i><\/i> 3<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\">                        \u6709\u4e2a\u9700\u6c42\uff0c\u9700\u8981\u5728 view \u4e2d\u5b8c\u6210\u67d0\u4e2a\u4e8b\u60c5\u540e\uff0c\u91cd\u65b0\u52a0\u8f7d django\uff0c\u80fd\u5b9e\u73b0\u5417\uff1f      <\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>8<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4098110\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : rogwan <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u4e2a\u9700\u6c42\u662f\u4e3a\u4e86\u4ec0\u4e48\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4098111\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Eyon <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u54c8\u54c8\uff0c\u9700\u6c42\u770b\u8d77\u6765\u5f88\u602a\u5f02\uff0c\u76f4\u63a5\u8bf4\u95ee\u9898\u5427\uff1a<\/p>\n<p>\u9700\u6c42\u662f\uff1a\u7528\u6237\u6bcf\u4e0a\u4f20\u4e00\u5f20\u56fe\u7247\uff0c\u5c31\u5c06\u8fd9\u5f20\u56fe\u7247\u4f5c\u4e3a\u9644\u4ef6\u53d1\u9001\u7ed9\u67d0\u4e2a\u90ae\u7bb1\u3002<\/p>\n<p>\u4f46\u73b0\u5728\u7684\u95ee\u9898\u662f\uff1f\u53d1\u9001\u90ae\u4ef6\u65f6\u9644\u4ef6\u4f1a\u5c06\u4e4b\u524d\u4e0a\u4f20\u7684\u56fe\u7247\u90fd\u4f5c\u4e3a\u9644\u4ef6\u53d1\u9001\uff08\u800c\u4e0d\u662f\u53ea\u53d1\u9001\u6700\u8fd1\u4e0a\u4f20\u7684\u4e00\u5f20\uff09\uff0c\u4e0d\u77e5\u9053\u95ee\u9898\u51fa\u5728\u54ea\u91cc\u3002\u3002\u3002<\/p>\n<p> if request.method == &#8216;POST&#8217;:<br \/> obj = UploadFile(request.POST,request.FILES)<br \/> fl = request.FILES.get(&#8216;f1&#8217;)<br \/> if not fl:<br \/> return HttpResponse(&#8216;please select file&#8217;)<br \/> with open(&#8216;uploads\/&#8217;+fl.name,&#8217;wb+&#8217;) as f:<br \/> f.write(fl.read())<br \/> with open(&#8216;uploads\/&#8217;+fl.name,&#8217;rb&#8217;) as ff:<br \/> msg.attach_file(ff.name)<br \/> msg.send()<br \/> os.remove(ff.name)<br \/> return HttpResponse(&#8216;success&#8217;)                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4098112\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Eyon <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @rogwan \u4f46\u662f\u91cd\u8f7d django \u5c31\u6ca1\u6709\u95ee\u9898                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4098113\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : qdzzyb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             msg \u662f\u4e0d\u662f\u4e00\u76f4\u90fd\u662f\u540c\u4e00\u4e2a\u5bf9\u8c61                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4098114\" 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>                                                             \u4f60\u9700\u8981\u505a\u7684\u662f\u6539\u53d8\u4e0a\u4f20\u5904\u7406\u7684\u903b\u8f91\uff0c\u800c\u4e0d\u662f\u91cd\u65b0\u52a0\u8f7d Django\uff0c\u6ca1\u6709\u54ea\u4e2a\u7f51\u7edc\u670d\u52a1\u53ef\u4ee5\u8fd9\u4e48\u53cd\u590d\u91cd\u542f\u7684\uff08 uwsgi \u7b49\u53ef\u4ee5\u5728\u82e5\u5e72 request \u540e\u91cd\u542f\u540e\u7aef\u662f\u53e6\u4e00\u56de\u4e8b\uff09\u3002<\/p>\n<p>\u5982\u679c\u4e0a\u4f20\u7684\u6587\u4ef6\u503c\u5f97\u505a\u4e2a\u8bb0\u5f55\uff0c\u5efa\u8bae\u52a0\u4e00\u4e2a\u6570\u636e\u8868\uff0c\u5305\u542b\u4e00\u4e2a FileField \u6570\u636e\u6bb5\u3002\u7136\u540e\u6309\u7167 Django \u6807\u51c6\u65b9\u6cd5\u4fdd\u5b58\u6587\u4ef6\u53ca\u76f8\u5173\u6570\u636e\uff0c\u518d\u53d1\u9001\u6587\u4ef6\u3002\u800c\u53d1\u9001\u90ae\u4ef6\u53ca\u9644\u4ef6\u6700\u597d\u4e22\u5230\u4efb\u52a1\u961f\u5217\u91cc\uff0c\u6709\u4e2a\u76f8\u5173\u7684\u6570\u636e\u8868\u66f4\u65b9\u4fbf\u63d0\u4ea4\u7ed9 celery \u4e4b\u7c7b\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4098115\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : linnchord <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u2026\u795e\u903b\u8f91\u2026\u6709\u79cd\u9ed1\u8272\u5e7d\u9ed8                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4098116\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Eyon <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @qdzzyb \u4e00\u8bed\u60ca\u9192\u68a6\u4e2d\u4eba\u54c8\u54c8\u54c8\uff0c\u65b0\u624b\u5c31\u662f\u8fd9\u6837\u8111\u58f3\u8f6c\u4e0d\u8fc7\u5f2f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4098117\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : rogwan <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e00\u4e2a request \u5c31\u91cd\u8f7d\u6574\u4e2a\u5e94\u7528\uff0c\u4f60\u8003\u8651\u4e0b\u8fd9\u4e2a\u670d\u52a1\u5668\u80fd\u652f\u6301\u51e0\u4e2a\u5e76\u53d1\u5440\uff0c\u662f\u8981\u51c6\u5907\u8dd1\u8def\u4e86\u5417                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u53ef\u4ee5\u5728 views \u4e2d\u91cd\u8f7d dja&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\/188462"}],"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=188462"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/188462\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=188462"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=188462"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=188462"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}