{"id":609,"date":"2020-07-23T10:04:00","date_gmt":"2020-07-23T02:04:00","guid":{"rendered":"https:\/\/kanghaov.com\/?p=609"},"modified":"2024-11-26T15:33:01","modified_gmt":"2024-11-26T07:33:01","slug":"django%e4%b8%ad%e4%b8%80%e7%a7%8d%e6%95%b0%e6%8d%ae%e5%ba%93%e8%ae%be%e7%bd%ae%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/nemo.cool\/609.html","title":{"rendered":"Django\u4e2d\u4e00\u79cd\u6570\u636e\u5e93\u8bbe\u7f6e\u65b9\u6cd5"},"content":{"rendered":"<p>\u8fd9\u4e2a\u65b9\u6cd5\u53ef\u4ee5\u9690\u85cf\u6570\u636e\u5e93\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u540e\u671f\u65b9\u4fbf\u66f4\u6539\uff0c\u79fb\u690d\u6027\u4e5f\u5f3a\uff1a<\/p>\n<p><code>settings.py<\/code><\/p>\n<pre><code class=\"language-python \">MY_CONF_PATH = os.path.join(BASE_DIR, 'my.cnf')\nDATABASES = {\n    # 'default': {\n    #     'ENGINE': 'django.db.backends.sqlite3',\n    #     'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),\n    # }#\n    'default': {\n        'ENGINE': 'django.db.backends.mysql',\n        'HOST': '127.0.0.1',\n        'PORT': '3306',\n        'OPTIONS': {\n            'read_default_file': MY_CONF_PATH,\n        }\n    }\n}\n\n<\/code><\/pre>\n<p><code>my.cnf<\/code><\/p>\n<pre><code class=\"\">[client]\ndatabase = test\nuser = root\npassword = 1234\ndefault-character-set = utf8\n\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u4e2a\u65b9\u6cd5\u53ef\u4ee5\u9690\u85cf\u6570\u636e\u5e93\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u540e\u671f\u65b9\u4fbf\u66f4\u6539\uff0c\u79fb\u690d\u6027\u4e5f\u5f3a\uff1a settings.py MY_CONF_PATH = os.path.join(BASE_DIR, &#8216;my.cnf&#8217;) DATABASES = { # &#8216;default&#8217;: { # &#8216;ENGINE&#8217;: &#8216;django.db.backends.sqlite3&#8217;, # &#8216;NAME&#8217;: os.path.join(BASE_DIR, &#8216;db.sqlite3&#8217;), # }# &#8216;default&#8217;: { &#8216;ENGINE&#8217;: &#8216;django.db.backends.mysql&#8217;, &#8216;HOST&#8217;: &#8216;127.0.0.1&#8217;, &#8216;PORT&#8217;: &#8216;3306&#8217;, &#8216;OPTIONS&#8217;: { &#8216;read_default_file&#8217;: MY_CONF_PATH, } } } my.cnf [client] database = test user = root password = 1234 default-character-set = utf8<\/p>\n","protected":false},"author":1,"featured_media":610,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[86,2],"tags":[],"class_list":["post-609","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dev","category-py"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Django\u4e2d\u4e00\u79cd\u6570\u636e\u5e93\u8bbe\u7f6e\u65b9\u6cd5 - Nemo<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/nemo.cool\/609.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Django\u4e2d\u4e00\u79cd\u6570\u636e\u5e93\u8bbe\u7f6e\u65b9\u6cd5 - Nemo\" \/>\n<meta property=\"og:description\" content=\"\u8fd9\u4e2a\u65b9\u6cd5\u53ef\u4ee5\u9690\u85cf\u6570\u636e\u5e93\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u540e\u671f\u65b9\u4fbf\u66f4\u6539\uff0c\u79fb\u690d\u6027\u4e5f\u5f3a\uff1a settings.py MY_CONF_PATH = os.path.join(BASE_DIR, &#039;my.cnf&#039;) DATABASES = { # &#039;default&#039;: { # &#039;ENGINE&#039;: &#039;django.db.backends.sqlite3&#039;, # &#039;NAME&#039;: os.path.join(BASE_DIR, &#039;db.sqlite3&#039;), # }# &#039;default&#039;: { &#039;ENGINE&#039;: &#039;django.db.backends.mysql&#039;, &#039;HOST&#039;: &#039;127.0.0.1&#039;, &#039;PORT&#039;: &#039;3306&#039;, &#039;OPTIONS&#039;: { &#039;read_default_file&#039;: MY_CONF_PATH, } } } my.cnf [client] database = test user = root password = 1234 default-character-set = utf8\" \/>\n<meta property=\"og:url\" content=\"https:\/\/nemo.cool\/609.html\" \/>\n<meta property=\"og:site_name\" content=\"Nemo\" \/>\n<meta property=\"article:published_time\" content=\"2020-07-23T02:04:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-26T07:33:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/nemo.cool\/wp-content\/uploads\/2020\/07\/timg.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Nemo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nemo\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/nemo.cool\\\/609.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nemo.cool\\\/609.html\"},\"author\":{\"name\":\"Nemo\",\"@id\":\"https:\\\/\\\/nemo.cool\\\/#\\\/schema\\\/person\\\/698f803ee811e2b140a90f5d5de913d2\"},\"headline\":\"Django\u4e2d\u4e00\u79cd\u6570\u636e\u5e93\u8bbe\u7f6e\u65b9\u6cd5\",\"datePublished\":\"2020-07-23T02:04:00+00:00\",\"dateModified\":\"2024-11-26T07:33:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/nemo.cool\\\/609.html\"},\"wordCount\":1,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/nemo.cool\\\/#\\\/schema\\\/person\\\/698f803ee811e2b140a90f5d5de913d2\"},\"image\":{\"@id\":\"https:\\\/\\\/nemo.cool\\\/609.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/nemo.cool\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/timg.jpg\",\"articleSection\":[\"Dev\",\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/nemo.cool\\\/609.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/nemo.cool\\\/609.html\",\"url\":\"https:\\\/\\\/nemo.cool\\\/609.html\",\"name\":\"Django\u4e2d\u4e00\u79cd\u6570\u636e\u5e93\u8bbe\u7f6e\u65b9\u6cd5 - Nemo\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nemo.cool\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/nemo.cool\\\/609.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/nemo.cool\\\/609.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/nemo.cool\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/timg.jpg\",\"datePublished\":\"2020-07-23T02:04:00+00:00\",\"dateModified\":\"2024-11-26T07:33:01+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/nemo.cool\\\/609.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/nemo.cool\\\/609.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/nemo.cool\\\/609.html#primaryimage\",\"url\":\"https:\\\/\\\/nemo.cool\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/timg.jpg\",\"contentUrl\":\"https:\\\/\\\/nemo.cool\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/timg.jpg\",\"width\":1280,\"height\":720},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/nemo.cool\\\/609.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\\\/\\\/nemo.cool\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Django\u4e2d\u4e00\u79cd\u6570\u636e\u5e93\u8bbe\u7f6e\u65b9\u6cd5\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/nemo.cool\\\/#website\",\"url\":\"https:\\\/\\\/nemo.cool\\\/\",\"name\":\"Nemo\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/nemo.cool\\\/#\\\/schema\\\/person\\\/698f803ee811e2b140a90f5d5de913d2\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/nemo.cool\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/nemo.cool\\\/#\\\/schema\\\/person\\\/698f803ee811e2b140a90f5d5de913d2\",\"name\":\"Nemo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/nemo.cool\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/Big_Hero_6_Anime_HD_desktop_wallpaper_01_1366x768-e1706020097529-96x96.jpg\",\"url\":\"https:\\\/\\\/nemo.cool\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/Big_Hero_6_Anime_HD_desktop_wallpaper_01_1366x768-e1706020097529-96x96.jpg\",\"contentUrl\":\"https:\\\/\\\/nemo.cool\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/Big_Hero_6_Anime_HD_desktop_wallpaper_01_1366x768-e1706020097529-96x96.jpg\",\"caption\":\"Nemo\"},\"logo\":{\"@id\":\"https:\\\/\\\/nemo.cool\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/Big_Hero_6_Anime_HD_desktop_wallpaper_01_1366x768-e1706020097529-96x96.jpg\"},\"sameAs\":[\"https:\\\/\\\/nemo.cool\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Django\u4e2d\u4e00\u79cd\u6570\u636e\u5e93\u8bbe\u7f6e\u65b9\u6cd5 - Nemo","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/nemo.cool\/609.html","og_locale":"en_US","og_type":"article","og_title":"Django\u4e2d\u4e00\u79cd\u6570\u636e\u5e93\u8bbe\u7f6e\u65b9\u6cd5 - Nemo","og_description":"\u8fd9\u4e2a\u65b9\u6cd5\u53ef\u4ee5\u9690\u85cf\u6570\u636e\u5e93\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u540e\u671f\u65b9\u4fbf\u66f4\u6539\uff0c\u79fb\u690d\u6027\u4e5f\u5f3a\uff1a settings.py MY_CONF_PATH = os.path.join(BASE_DIR, 'my.cnf') DATABASES = { # 'default': { # 'ENGINE': 'django.db.backends.sqlite3', # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), # }# 'default': { 'ENGINE': 'django.db.backends.mysql', 'HOST': '127.0.0.1', 'PORT': '3306', 'OPTIONS': { 'read_default_file': MY_CONF_PATH, } } } my.cnf [client] database = test user = root password = 1234 default-character-set = utf8","og_url":"https:\/\/nemo.cool\/609.html","og_site_name":"Nemo","article_published_time":"2020-07-23T02:04:00+00:00","article_modified_time":"2024-11-26T07:33:01+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/nemo.cool\/wp-content\/uploads\/2020\/07\/timg.jpg","type":"image\/jpeg"}],"author":"Nemo","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Nemo"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/nemo.cool\/609.html#article","isPartOf":{"@id":"https:\/\/nemo.cool\/609.html"},"author":{"name":"Nemo","@id":"https:\/\/nemo.cool\/#\/schema\/person\/698f803ee811e2b140a90f5d5de913d2"},"headline":"Django\u4e2d\u4e00\u79cd\u6570\u636e\u5e93\u8bbe\u7f6e\u65b9\u6cd5","datePublished":"2020-07-23T02:04:00+00:00","dateModified":"2024-11-26T07:33:01+00:00","mainEntityOfPage":{"@id":"https:\/\/nemo.cool\/609.html"},"wordCount":1,"commentCount":0,"publisher":{"@id":"https:\/\/nemo.cool\/#\/schema\/person\/698f803ee811e2b140a90f5d5de913d2"},"image":{"@id":"https:\/\/nemo.cool\/609.html#primaryimage"},"thumbnailUrl":"https:\/\/nemo.cool\/wp-content\/uploads\/2020\/07\/timg.jpg","articleSection":["Dev","Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/nemo.cool\/609.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/nemo.cool\/609.html","url":"https:\/\/nemo.cool\/609.html","name":"Django\u4e2d\u4e00\u79cd\u6570\u636e\u5e93\u8bbe\u7f6e\u65b9\u6cd5 - Nemo","isPartOf":{"@id":"https:\/\/nemo.cool\/#website"},"primaryImageOfPage":{"@id":"https:\/\/nemo.cool\/609.html#primaryimage"},"image":{"@id":"https:\/\/nemo.cool\/609.html#primaryimage"},"thumbnailUrl":"https:\/\/nemo.cool\/wp-content\/uploads\/2020\/07\/timg.jpg","datePublished":"2020-07-23T02:04:00+00:00","dateModified":"2024-11-26T07:33:01+00:00","breadcrumb":{"@id":"https:\/\/nemo.cool\/609.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/nemo.cool\/609.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/nemo.cool\/609.html#primaryimage","url":"https:\/\/nemo.cool\/wp-content\/uploads\/2020\/07\/timg.jpg","contentUrl":"https:\/\/nemo.cool\/wp-content\/uploads\/2020\/07\/timg.jpg","width":1280,"height":720},{"@type":"BreadcrumbList","@id":"https:\/\/nemo.cool\/609.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/nemo.cool\/"},{"@type":"ListItem","position":2,"name":"Django\u4e2d\u4e00\u79cd\u6570\u636e\u5e93\u8bbe\u7f6e\u65b9\u6cd5"}]},{"@type":"WebSite","@id":"https:\/\/nemo.cool\/#website","url":"https:\/\/nemo.cool\/","name":"Nemo","description":"","publisher":{"@id":"https:\/\/nemo.cool\/#\/schema\/person\/698f803ee811e2b140a90f5d5de913d2"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/nemo.cool\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/nemo.cool\/#\/schema\/person\/698f803ee811e2b140a90f5d5de913d2","name":"Nemo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/nemo.cool\/wp-content\/uploads\/2024\/01\/Big_Hero_6_Anime_HD_desktop_wallpaper_01_1366x768-e1706020097529-96x96.jpg","url":"https:\/\/nemo.cool\/wp-content\/uploads\/2024\/01\/Big_Hero_6_Anime_HD_desktop_wallpaper_01_1366x768-e1706020097529-96x96.jpg","contentUrl":"https:\/\/nemo.cool\/wp-content\/uploads\/2024\/01\/Big_Hero_6_Anime_HD_desktop_wallpaper_01_1366x768-e1706020097529-96x96.jpg","caption":"Nemo"},"logo":{"@id":"https:\/\/nemo.cool\/wp-content\/uploads\/2024\/01\/Big_Hero_6_Anime_HD_desktop_wallpaper_01_1366x768-e1706020097529-96x96.jpg"},"sameAs":["https:\/\/nemo.cool"]}]}},"_links":{"self":[{"href":"https:\/\/nemo.cool\/wp-json\/wp\/v2\/posts\/609","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nemo.cool\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nemo.cool\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nemo.cool\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nemo.cool\/wp-json\/wp\/v2\/comments?post=609"}],"version-history":[{"count":0,"href":"https:\/\/nemo.cool\/wp-json\/wp\/v2\/posts\/609\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nemo.cool\/wp-json\/wp\/v2\/media\/610"}],"wp:attachment":[{"href":"https:\/\/nemo.cool\/wp-json\/wp\/v2\/media?parent=609"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nemo.cool\/wp-json\/wp\/v2\/categories?post=609"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nemo.cool\/wp-json\/wp\/v2\/tags?post=609"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}