{"id":174065,"date":"2020-10-26T03:21:26","date_gmt":"2020-10-25T19:21:26","guid":{"rendered":"http:\/\/4563.org\/?p=174065"},"modified":"2020-10-26T03:21:26","modified_gmt":"2020-10-25T19:21:26","slug":"django-views-%e4%b8%ad%e4%bb%8e%e5%89%8d%e7%ab%af%e8%8e%b7%e5%8f%96%e5%88%b0%e7%9a%84%e5%af%b9%e8%b1%a1%e5%a6%82%e4%bd%95%e4%bc%a0%e9%80%92%e7%bb%99-test-py-%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=174065","title":{"rendered":"django views \u4e2d\u4ece\u524d\u7aef\u83b7\u53d6\u5230\u7684\u5bf9\u8c61\u5982\u4f55\u4f20\u9012\u7ed9 test.py \u6587\u4ef6"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  django views \u4e2d\u4ece\u524d\u7aef\u83b7\u53d6\u5230\u7684\u5bf9\u8c61\u5982\u4f55\u4f20\u9012\u7ed9 test.py \u6587\u4ef6               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : tibifide <\/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>api \u81ea\u52a8\u5316\uff0c\u4ece\u9875\u9762\u4e0a\u9762\u83b7\u53d6\u5230\u4e86\u6d4b\u8bd5\u7528\u4f8b\u7684 id\uff0cviews \u4e2d\u5f97\u5230\u4e86\u540e\u8bbe\u7f6e global \u6253\u7b97\u4f5c\u4e3a\u5168\u5c40\u53d8\u91cf\uff0c\u8c03\u7528\u4e86&#8221;python manage.py test&#8221;\u6267\u884c\uff0c\u4f3c\u4e4e\u5f00\u542f\u4e86\u4e00\u4e2a\u65b0\u7684\u8fdb\u7a0b\uff0cpython \u4e2d\u7ebf\u7a0b\u4e4b\u95f4\u5171\u4eab\u53d8\u91cf\u53ef\u4ee5\u4f7f\u7528 global\uff0c\u8fd9\u6837\u5b50\u83b7\u53d6\u4e0d\u5230\uff0c\u6709\u522b\u7684\u529e\u6cd5\u5417\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>2<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3892279\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : tibifide <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8bbe\u60f3\u7684\u6d41\u7a0b\u662f\u8fd9\u6837\uff0c\u524d\u7aef post \u9700\u8981\u6267\u884c\u7528\u4f8b\u7684 id\uff0c\u7136\u540e\u5728 django \u7684 views \u4e2d\u53bb\u8c03\u7528&#8221;python manage.py test&#8221;\uff0c\u60f3\u7528 django \u81ea\u8eab\u7684 unittest\uff0c\u83b7\u53d6\u5230\u62a5\u544a\uff0c\u6240\u4ee5\u8981\u6267\u884c\u8fd9\u4e2a\u547d\u4ee4\uff0c\u4f46\u6267\u884c\u4e86\u8fd9\u4e2a\u547d\u4ee4\u540e\uff0c\u5f00\u542f\u4e86\u4e00\u4e2a\u65b0\u7684\u8fdb\u7a0b\u5c31\u83b7\u53d6\u4e0d\u5230 views \u4e2d\u5b9a\u4e49\u7684\u5168\u5c40\u53d8\u91cf                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3892280\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : EminemW <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             test.py \u662f\u53ef\u4ee5\u63a5\u6536\u547d\u4ee4\u884c\u53c2\u6570\u7684\u5427\uff0c\u8bbe\u7f6e\u597d\u8981\u63a5\u6536\u53c2\u6570\uff0c\u8c03\u7528\u7684\u65f6\u5019\u53ef\u4ee5\u4f8b\u5982\u8fd9\u6837 &#8220;python manage.py test &#8211;id 1234&#8221;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>django views \u4e2d\u4ece\u524d\u7aef&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\/174065"}],"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=174065"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/174065\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=174065"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=174065"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=174065"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}