{"id":26649,"date":"2024-11-24T08:30:06","date_gmt":"2024-11-24T00:30:06","guid":{"rendered":"https:\/\/fwq.ai\/blog\/26649\/"},"modified":"2024-11-24T08:30:06","modified_gmt":"2024-11-24T00:30:06","slug":"pycharm-%e4%b8%ad%e4%bd%bf%e7%94%a8-django-%e6%97%a0%e6%b3%95%e5%88%9b%e5%bb%ba-mysql-%e6%95%b0%e6%8d%ae%e8%a1%a8%ef%bc%9a%e4%b8%ba%e4%bb%80%e4%b9%88%e6%88%91%e7%9a%84%e6%95%b0%e6%8d%ae%e8%a1%a8-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/26649\/","title":{"rendered":"PyCharm \u4e2d\u4f7f\u7528 Django \u65e0\u6cd5\u521b\u5efa MySQL \u6570\u636e\u8868\uff1a\u4e3a\u4ec0\u4e48\u6211\u7684\u6570\u636e\u8868\u6ca1\u6709\u751f\u6210\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173103715139418.jpg\" class=\"aligncenter\" title=\"PyCharm \u4e2d\u4f7f\u7528 Django \u65e0\u6cd5\u521b\u5efa MySQL \u6570\u636e\u8868\uff1a\u4e3a\u4ec0\u4e48\u6211\u7684\u6570\u636e\u8868\u6ca1\u6709\u751f\u6210\uff1f\u63d2\u56fe\" alt=\"PyCharm \u4e2d\u4f7f\u7528 Django \u65e0\u6cd5\u521b\u5efa MySQL \u6570\u636e\u8868\uff1a\u4e3a\u4ec0\u4e48\u6211\u7684\u6570\u636e\u8868\u6ca1\u6709\u751f\u6210\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5728  \u4e2d\u4f7f\u7528 django \u65e0\u6cd5\u6210\u529f\u521b\u5efa  \u6570\u636e\u8868<\/strong><\/p>\n<p>\u5728 pycharm \u4e2d\u4f7f\u7528 django \u8fde\u63a5 mysql \u6570\u636e\u5e93\u540e\uff0c\u5728\u6267\u884c\u201c3 manage.py makemigrations\u201d\u547d\u4ee4\u540e\u5374\u53d1\u73b0 mysql \u6570\u636e\u8868\u6ca1\u6709\u521b\u5efa\u6210\u529f\u3002<\/p>\n<p><strong>\u7cfb\u7edf\u73af\u5883\uff1a<\/strong><\/p>\n<ul>\n<li>  10<\/li>\n<li>python 3.8.6<\/li>\n<li>django 3.2.19<\/li>\n<li>mysqlclient 2.1.1<\/li>\n<li>mysql 0.0.3<\/li>\n<\/ul>\n<p><strong>\u9879\u76ee\u914d\u7f6e\uff1a<\/strong><\/p>\n<ul>\n<li>models.py \u4e2d\u5b9a\u4e49\u4e86\u6a21\u578b<\/li>\n<li>settings.py \u4e2d\u6ce8\u518c\u4e86 app \u5e76\u914d\u7f6e\u6570\u636e\u5e93\u4fe1\u606f<\/li>\n<\/ul>\n<p><strong>\u95ee\u9898\u73b0\u8c61\uff1a<\/strong><\/p>\n<ul>\n<li>\u8fd0\u884c\u201cpython3 manage.py makemigrations\u201d\u548c\u201cpython3 manage.py migrate\u201d\u547d\u4ee4\u540e\uff0cmysql \u4e2d\u6ca1\u6709\u521b\u5efa\u6570\u636e\u8868\u3002<\/li>\n<\/ul>\n<p><strong>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/strong><\/p>\n<p>\u7ecf\u8fc7\u4ed4\u7ec6\u68c0\u67e5\uff0c\u53d1\u73b0\u8be5\u95ee\u9898\u662f\u7531 python 3 \u7684\u7248\u672c\u51b2\u7a81\u5f15\u8d77\u7684\u3002\u5728 windows \u73af\u5883\u4e2d\uff0c\u4f7f\u7528\u201cpython3\u201d\u547d\u4ee4\u53ef\u80fd\u4f1a\u6267\u884c windows \u81ea\u5e26\u7684 python 3\uff0c\u800c\u4e0d\u662f\u5b89\u88c5\u7684 python 3.8.6\u3002\u56e0\u6b64\uff0c\u9700\u8981\u660e\u786e\u6307\u5b9a python \u89e3\u91ca\u5668\uff1a<\/p>\n<pre>python manage.py makemigrations\npython manage.py migrate<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n<ul>\n<li>\u8fd0\u884c\u201cpython\u201d\u547d\u4ee4\uff0c\u5982\u679c\u6253\u5f00\u7684\u662f windows \u5e94\u7528\u5546\u5e97\uff0c\u5219\u8bf4\u660e\u5f53\u524d\u73af\u5883\u4f7f\u7528\u7684 python 3 \u662f windows \u81ea\u5e26\u7684\u3002<\/li>\n<li>\u6b63\u786e\u5b89\u88c5\u7684 python 3 \u5e94\u8be5\u53ef\u4ee5\u901a\u8fc7\u76f4\u63a5\u8fd0\u884c\u201cpython\u201d\u547d\u4ee4\u8fdb\u5165\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fPyCharm \u4e2d\u4f7f\u7528 Django \u65e0\u6cd5\u521b\u5efa MySQL \u6570\u636e\u8868\uff1a\u6211\u7684\u6570\u636e\u8868\u6ca1\u6709\u751f\u6210\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 \u4e2d\u4f7f\u7528 django \u65e0\u6cd5\u6210\u529f\u521b\u5efa \u6570\u636e\u8868 \u5728 pycharm \u4e2d\u4f7f\u7528 django \u8fde\u63a5 mysql \u6570\u636e\u5e93\u540e\uff0c\u5728\u6267\u884c\u201c3 manage.py makemigrations\u201d\u547d\u4ee4\u540e\u5374\u53d1\u73b0 mysql \u6570\u636e\u8868\u6ca1\u6709\u521b\u5efa\u6210\u529f\u3002 \u7cfb\u7edf\u73af\u5883\uff1a 10 python 3.8.6 django 3.2.19 mysqlclient 2.1.1 mysql 0.0.3 \u9879\u76ee\u914d\u7f6e\uff1a models.py \u4e2d\u5b9a\u4e49\u4e86\u6a21\u578b settings.py \u4e2d\u6ce8\u518c\u4e86 app \u5e76\u914d\u7f6e\u6570\u636e\u5e93\u4fe1\u606f \u95ee\u9898\u73b0\u8c61\uff1a \u8fd0\u884c\u201cpython3 manage.py makemigrations\u201d\u548c\u201cpython3 manage.py migrate\u201d\u547d\u4ee4\u540e\uff0cmysql \u4e2d\u6ca1\u6709\u521b\u5efa\u6570\u636e\u8868\u3002 \u89e3\u51b3\u65b9\u6cd5\uff1a \u7ecf\u8fc7\u4ed4\u7ec6\u68c0\u67e5\uff0c\u53d1\u73b0\u8be5\u95ee\u9898\u662f\u7531 python 3 \u7684\u7248\u672c\u51b2\u7a81\u5f15\u8d77\u7684\u3002\u5728 windows \u73af\u5883\u4e2d\uff0c\u4f7f\u7528\u201cpython3\u201d\u547d\u4ee4\u53ef\u80fd\u4f1a\u6267\u884c windows \u81ea\u5e26\u7684 python 3\uff0c\u800c\u4e0d\u662f\u5b89\u88c5\u7684 python 3.8.6\u3002\u56e0\u6b64\uff0c\u9700\u8981\u660e\u786e\u6307\u5b9a python \u89e3\u91ca\u5668\uff1a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-26649","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26649","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=26649"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26649\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=26649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=26649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=26649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}