{"id":200605,"date":"2025-05-06T12:45:34","date_gmt":"2025-05-06T04:45:34","guid":{"rendered":"https:\/\/server.hk\/cnblog\/200605\/"},"modified":"2025-05-06T12:45:34","modified_gmt":"2025-05-06T04:45:34","slug":"python-django-%e6%95%b0%e6%8d%ae%e5%ba%93%e8%bf%81%e7%a7%bb%e5%a4%b1%e8%b4%a5%ef%bc%9a%e4%b8%ba%e4%bb%80%e4%b9%88-python3-manage-py-makemigrations-%e5%9c%a8-windows-%e4%b8%8a%e6%97%a0%e6%b3%95","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/200605\/","title":{"rendered":"Python Django \u6570\u636e\u5e93\u8fc1\u79fb\u5931\u8d25\uff1a\u4e3a\u4ec0\u4e48 `python3 manage.py makemigrations` \u5728 Windows \u4e0a\u65e0\u6cd5\u521b\u5efa MySQL \u6570\u636e\u8868\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>Python Django \u6570\u636e\u5e93\u8fc1\u79fb\u5931\u8d25\uff1a\u4e3a\u4ec0\u4e48 `python3 manage.py makemigrations` \u5728 Windows \u4e0a\u65e0\u6cd5\u521b\u5efa MySQL \u6570\u636e\u8868\uff1f<\/h1>\n<p>\u5927\u5bb6\u597d\uff0c\u4eca\u5929\u672c\u4eba\u7ed9\u5927\u5bb6\u5e26\u6765\u6587\u7ae0\uff0c\u6587\u4e2d\u5185\u5bb9\u4e3b\u8981\u6d89\u53ca\u5230\uff0c\u5982\u679c\u4f60\u5bf9\u65b9\u9762\u7684\u77e5\u8bc6\u70b9\u611f\u5174\u8da3\uff0c\u90a3\u5c31\u8bf7\u5404\u4f4d\u670b\u53cb\u7ee7\u7eed\u770b\u4e0b\u53bb\u5427~\u5e0c\u671b\u80fd\u771f\u6b63\u5e2e\u5230\u4f60\u4eec\uff0c\u8c22\u8c22\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241109\/1731148244672f39d45a4fb.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>Python Django \u6570\u636e\u5e93\u8fc1\u79fb\u5931\u8d25<\/strong><\/p>\n<p>\u5728\u6267\u884c python3 manage.py makemigrations \u547d\u4ee4\u65f6\uff0c\u9047\u5230\u4e86 MySQL \u6570\u636e\u8868\u521b\u5efa\u5931\u8d25\u7684\u95ee\u9898\u3002\u4ee5\u4e0b\u662f\u95ee\u9898\u8be6\u60c5\uff1a<\/p>\n<ul>\n<li>\u64cd\u4f5c\u7cfb\u7edf\uff1aWindows 10<\/li>\n<li>Python \u7248\u672c\uff1a3.8.6<\/li>\n<li>Django \u7248\u672c\uff1a3.2.19<\/li>\n<li>mysqlclient \u7248\u672c\uff1a2.1.1<\/li>\n<li>MySQL \u7248\u672c\uff1a0.0.3<\/li>\n<\/ul>\n<p>\u9879\u76ee\u7684\u76ee\u5f55\u7ed3\u6784\u3001models.py \u6587\u4ef6\u5185\u5bb9\uff0c\u4ee5\u53ca settings.py \u6587\u4ef6\u4e2d\u7684\u5e94\u7528\u7a0b\u5e8f\u6ce8\u518c\u548c\u6570\u636e\u5e93\u914d\u7f6e\u90fd\u5df2\u786e\u8ba4\u65e0\u8bef\u3002<\/p>\n<p>\u7136\u800c\uff0c\u5728\u8fd0\u884c python3 manage.py makemigrations \u548c python3 manage.py migrate \u547d\u4ee4\u540e\uff0cMySQL \u4e2d\u7684\u6570\u636e\u8868\u4ecd\u672a\u521b\u5efa\u6210\u529f\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u7ecf\u8fc7\u5206\u6790\uff0c\u95ee\u9898\u51fa\u5728\u4f7f\u7528\u7684 Python \u89e3\u91ca\u5668\u4e0a\u3002\u6267\u884c python3 \u547d\u4ee4\u5b9e\u9645\u4e0a\u6307\u5411\u7684\u662f Windows \u81ea\u5e26\u7684 Python \u89e3\u91ca\u5668\uff0c\u800c\u4e0d\u662f\u5b89\u88c5\u5305\u4e2d\u5b89\u88c5\u7684 Python \u89e3\u91ca\u5668\u3002<\/p>\n<p><strong>\u89e3\u51b3\u6b65\u9aa4\uff1a<\/strong><\/p>\n<ol>\n<li>\u4f7f\u7528 python \u547d\u4ee4\uff08\u4e0d\u5e26\u7248\u672c\u53f7\uff09\u6765\u8c03\u7528\u5b89\u88c5\u5305\u5b89\u88c5\u7684 Python \u89e3\u91ca\u5668\u3002<\/li>\n<li>\u5728 python \u89e3\u91ca\u5668\u4e2d\uff0c\u8f93\u5165 python manage.py makemigrations \u548c python manage.py migrate \u547d\u4ee4\u3002\u6b64\u65f6\uff0c\u6570\u636e\u8868\u5c06\u6210\u529f\u521b\u5efa\u3002<\/li>\n<\/ol>\n<p>\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u4e5f\u5c31\u8bb2\u5b8c\u4e86\u300aPython Django \u6570\u636e\u5e93\u8fc1\u79fb\u5931\u8d25\uff1a\u4e3a\u4ec0\u4e48 `python3 manage.py makemigrations` \u5728 Windows \u4e0a\u65e0\u6cd5\u521b\u5efa MySQL \u6570\u636e\u8868\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\u4e3b\u673a\u5b9d\u8d1d\u516c\u4f17\u53f7\uff0c\u5e26\u4f60\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u77e5\u8bc6\u70b9\uff01<\/p>\n<dl>\n<dt>\n <\/dt>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>Python Django \u6570\u636e&#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":[101],"tags":[],"class_list":["post-200605","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200605","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=200605"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200605\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=200605"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=200605"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=200605"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}