{"id":5398,"date":"2024-02-29T15:13:45","date_gmt":"2024-02-29T07:13:45","guid":{"rendered":"http:\/\/www.menglanglang.cn\/?p=5398"},"modified":"2024-02-29T15:13:46","modified_gmt":"2024-02-29T07:13:46","slug":"django-%e6%a1%86%e6%9e%b6%e5%ad%a6%e4%b9%a0%e5%85%a5%e9%97%a8%e6%95%99%e7%a8%8b%ef%bc%88%e4%ba%8c%ef%bc%89-django-%e6%a1%86%e6%9e%b6%e4%bd%bf%e7%94%a8%e5%b8%b8%e8%a7%81%e8%ad%a6","status":"publish","type":"post","link":"http:\/\/www.menglanglang.cn\/?p=5398","title":{"rendered":"DJango \u6846\u67b6\u5b66\u4e60\u5165\u95e8\u6559\u7a0b\uff08\u4e8c\uff09 \u2014\u2014 DJango \u6846\u67b6\u4f7f\u7528\u5e38\u89c1\u8b66\u544a"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">\u8b66\u544a\u4e00\uff1a<\/h3>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" height=\"293\" width=\"900\" src=\"\/\/images.weserv.nl\/?url=https:\/\/img-blog.csdnimg.cn\/direct\/7cccf7e150b34c2d9cb822cf54ec97ec.png\" alt=\"\"\/>\u200b<\/p>\n\n\n\n<p>\u5728\u4f7f\u7528 DJango \u6846\u67b6\u6267\u884c\u8fc1\u79fb\u6587\u4ef6\u7684\u547d\u4ee4\u65f6\uff0c\u53ef\u4ee5\u770b\u5230\u51fa\u73b0\u5982\u4e0b\u8b66\u544a\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>(ll_env) D:\\workspace\\workspace-mengll\\learning-log&gt;<strong>python manage.py migrate<\/strong><br \/>System check identified some issues:<\/p>\n\n\n\n<p>WARNINGS:<br \/>?: (mysql.W002) MySQL Strict Mode is not set for database connection 'default'<br \/>&nbsp; &nbsp; &nbsp; &nbsp; HINT: MySQL's Strict Mode fixes many data integrity problems in MySQL, such as data truncation upon insertion, by escalating warnings into errors. It is strongly recommended you activate it. See: https:\/\/docs.djangoproject.com\/en\/5.0\/ref\/databases\/#mysql-sql-mode<br \/>Operations to perform:<br \/>&nbsp; Apply all migrations: admin, auth, contenttypes, learning_logs, sessions<br \/>Running migrations:<br \/>&nbsp; Applying learning_logs.0001_initial... OK<\/p>\n\n\n\n<p>(ll_env) D:\\workspace\\workspace-mengll\\learning-log&gt;<\/p>\n<\/blockquote>\n\n\n\n<p>\u867d\u7136\u53ef\u4ee5\u770b\u5230\u8fc1\u79fb\u6587\u4ef6\u6267\u884c\u6210\u529f\uff0c\u4e14\u6570\u636e\u5e93\u4e2d\u4e5f\u521b\u5efa\u6210\u529f\u4e86\u5bf9\u5e94\u7684\u8868\uff0c\u4f46\u5bf9\u4e8e\u7a0d\u6709\u5f3a\u8feb\u75c7\u7684\u6211\u4eec\u6765\u8bf4\u603b\u611f\u89c9\u4e0d\u723d\uff0c\u9700\u8981\u628a\u8b66\u544a\u5e72\u6389\u624d\u884c\uff0c\u53bb\u6389\u8b66\u544a\u4fe1\u606f\u7684\u914d\u7f6e\u65b9\u5f0f\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p>\u4fee\u6539 DJango \u521b\u5efa\u7684\u5e94\u7528\u7a0b\u5e8f\u4e0b\u7684&nbsp;settings.py \u914d\u7f6e\u6587\u4ef6\uff0c\u627e\u5230\u6570\u636e\u5e93\u4fe1\u606f\u914d\u7f6e\u7684\u90e8\u5206\uff0c\u6dfb\u52a0&nbsp;sql_mode \u914d\u7f6e\u5373\u53ef\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DATABASES = {\n    'default': {\n        # 'ENGINE': 'django.db.backends.sqlite3',\n        # 'NAME': BASE_DIR \/ 'db.sqlite3',\n        'ENGINE': 'django.db.backends.mysql',  # \u6570\u636e\u5e93\u5f15\u64ce\n        'NAME': '\u6570\u636e\u5e93\u540d\u79f0',  # \u6570\u636e\u5e93\u540d\u79f0\n        'HOST': '\u6570\u636e\u5e93\u5730\u5740',  # \u6570\u636e\u5e93\u5730\u5740\uff0c\u672c\u673a ip \u5730\u5740 127.0.0.1\n        'PORT': \u6570\u636e\u5e93\u7aef\u53e3,  # \u7aef\u53e3\n        'USER': '\u6570\u636e\u5e93\u7528\u6237\u540d',  # \u6570\u636e\u5e93\u7528\u6237\u540d\n        'PASSWORD': '\u6570\u636e\u5e93\u5bc6\u7801',  # \u6570\u636e\u5e93\u5bc6\u7801\n        'OPTIONS': {\n            'init_command': \"SET sql_mode='STRICT_TRANS_TABLES'\",\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<p>\u540e\u7eed\u518d\u6267\u884c\u8fc1\u79fb\u6587\u4ef6\uff0c\u53ef\u4ee5\u770b\u5230\u8b66\u544a\u5df2\u6d88\u9664\u3002 \u200b<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8b66\u544a\u4e00\uff1a \u200b \u5728\u4f7f\u7528 DJango \u6846\u67b6\u6267\u884c\u8fc1\u79fb\u6587\u4ef6\u7684\u547d\u4ee4\u65f6\uff0c\u53ef\u4ee5\u770b\u5230\u51fa\u73b0\u5982\u4e0b\u8b66\u544a\uff1a (ll_env) D:\\ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[921],"tags":[922,186,813,680,332],"class_list":["post-5398","post","type-post","status-publish","format-standard","hentry","category-django","tag-django","tag-mysql","tag-python","tag-warning","tag-332"],"_links":{"self":[{"href":"http:\/\/www.menglanglang.cn\/index.php?rest_route=\/wp\/v2\/posts\/5398","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.menglanglang.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.menglanglang.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.menglanglang.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.menglanglang.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5398"}],"version-history":[{"count":1,"href":"http:\/\/www.menglanglang.cn\/index.php?rest_route=\/wp\/v2\/posts\/5398\/revisions"}],"predecessor-version":[{"id":5399,"href":"http:\/\/www.menglanglang.cn\/index.php?rest_route=\/wp\/v2\/posts\/5398\/revisions\/5399"}],"wp:attachment":[{"href":"http:\/\/www.menglanglang.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.menglanglang.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5398"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.menglanglang.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}