{"id":204668,"date":"2025-05-29T09:13:39","date_gmt":"2025-05-29T01:13:39","guid":{"rendered":"https:\/\/server.hk\/cnblog\/204668\/"},"modified":"2025-05-29T09:13:39","modified_gmt":"2025-05-29T01:13:39","slug":"django-%e5%a4%9a%e5%ba%94%e7%94%a8%e4%b8%ad%e6%a8%a1%e5%9e%8b%e5%bc%95%e7%94%a8%ef%bc%9a%e4%b8%ba%e4%bb%80%e4%b9%88-pycharm-%e6%8a%a5%e9%94%99%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/204668\/","title":{"rendered":"Django \u591a\u5e94\u7528\u4e2d\u6a21\u578b\u5f15\u7528\uff1a\u4e3a\u4ec0\u4e48 PyCharm \u62a5\u9519\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Django \u591a\u5e94\u7528\u4e2d\u6a21\u578b\u5f15\u7528\uff1a\u4e3a\u4ec0\u4e48 PyCharm \u62a5\u9519\uff1f<\/h1>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241112\/173141968367335e231d552.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>django \u591a\u5e94\u7528\u4e2d\u7684\u6a21\u578b\u5f15\u7528<\/strong><\/p>\n<p>\u5728 django \u4e2d\u6784\u5efa\u591a\u5e94\u7528\u9879\u76ee\u65f6\uff0c\u9700\u8981\u8de8\u5e94\u7528\u5f15\u7528\u6a21\u578b\u3002\u4ee5\u4e0b\u6f14\u793a\u5982\u4f55\u5728 talk \u5e94\u7528\u4e2d\u5f15\u7528 user \u5e94\u7528\u4e2d\u7684\u6a21\u578b\uff1a<\/p>\n<pre>from ..user.models import usermodels<\/pre>\n<p>\u4f46\u6b64\u65f6\u53ef\u80fd\u4f1a\u9047\u5230\u4ee5\u4e0b\u62a5\u9519\uff1a<\/p>\n<pre>importerror: attempted relative import beyond top-level package<\/pre>\n<p>\u5b98\u65b9\u6587\u6863\u4e2d\u8868\u660e\u8fd9\u79cd\u5f15\u7528\u65b9\u5f0f\u662f\u6b63\u786e\u7684\u3002\u4f46 pycharm \u53ef\u80fd\u4f1a\u6709\u8b66\u544a\uff0c\u8ba4\u4e3a\u8def\u5f84\u6709\u8bef\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6cd5<\/strong><\/p>\n<p>\u5b9e\u9645\u4e0a\uff0cpycharm \u7684\u8b66\u544a\u53ef\u4ee5\u5ffd\u7565\uff0c\u5f15\u7528\u4ecd\u7136\u53ef\u4ee5\u6b63\u5e38\u5de5\u4f5c\u3002\u8fd9\u53ef\u80fd\u662f\u7531\u4e8e django \u7684\u76ee\u5f55\u7ed3\u6784\u66f4\u65b0\u9020\u6210\u7684\u3002<\/p>\n<p>\u6b63\u786e\u5f15\u5165\u65b9\u5f0f\uff1a<\/p>\n<pre>from user.models import usermodels<\/pre>\n<p>\u5176\u4e2d user \u4e3a user \u5e94\u7528\u7684\u76ee\u5f55\u540d\u79f0\u3002<\/p>\n<p>\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u4e5f\u5c31\u8bb2\u5b8c\u4e86\u300aDjango \u591a\u5e94\u7528\u4e2d\u6a21\u578b\u5f15\u7528\uff1a\u4e3a\u4ec0\u4e48 PyCharm \u62a5\u9519\uff1f\u300b\u7684\u5185\u5bb9\u4e86\u3002\u4e2a\u4eba\u8ba4\u4e3a\uff0c\u57fa\u7840\u77e5\u8bc6\u7684\u5b66\u4e60\u548c\u5de9\u56fa\uff0c\u662f\u4e3a\u4e86\u66f4\u597d\u7684\u5c06\u5176\u8fd0\u7528\u5230\u9879\u76ee\u4e2d\uff0c\u6b22\u8fce\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u5e26\u4f60\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u77e5\u8bc6\u70b9\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Django \u591a\u5e94\u7528\u4e2d\u6a21\u578b\u5f15\u7528\uff1a&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-204668","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204668","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=204668"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204668\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=204668"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=204668"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=204668"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}