{"id":352828,"date":"2023-05-12T04:00:00","date_gmt":"2023-05-12T03:00:00","guid":{"rendered":"https:\/\/blog.jetbrains.com\/?post_type=pycharm&#038;p=352828"},"modified":"2023-05-12T04:00:02","modified_gmt":"2023-05-12T03:00:02","slug":"pycharm-django-2","status":"publish","type":"pycharm","link":"https:\/\/blog.jetbrains.com\/zh-hans\/pycharm\/2023\/05\/pycharm-django-2\/","title":{"rendered":"\u5728 PyCharm \u4e2d\u521b\u5efa Django \u5e94\u7528"},"content":{"rendered":"<p>Django \u7684\u6838\u5fc3\u601d\u60f3\u662f\u8ba9\u5f00\u53d1\u8005\u5feb\u901f\u6784\u5efa\u5e94\u7528\u7a0b\u5e8f\u3002 \u638c\u63e1\u8fd9\u4e2a\u6846\u67b6\u540e\uff0c\u4ece\u6982\u5ff5\u5230\u53ef\u4ee5\u6295\u5165\u751f\u4ea7\u7684 Web \u5e94\u7528\u7a0b\u5e8f\u7684\u8def\u5f84\u5c06\u5927\u5e45\u7f29\u77ed\u3002 \u4f46\u662f\uff0c\u5982\u679c\u60a8\u8fd8\u60f3\u66f4\u5feb\uff0c\u53ef\u4ee5\u5b66\u4e60\u5728 PyCharm \u4e2d\u521b\u5efa Django \u5e94\u7528\u3002<\/p>\n<p>\u672c\u6559\u7a0b\u5c06\u901a\u8fc7\u4e00\u7cfb\u5217\u6b65\u9aa4\u6307\u5bfc\u60a8\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684 Django \u5e94\u7528\u7a0b\u5e8f\uff0c\u663e\u793a\u6240\u5728\u4f4d\u7f6e\u7684\u5f53\u524d\u6c14\u6e29\u3002 \u4e3a\u4e86\u589e\u52a0\u4e92\u52a8\u6027\uff0c\u8fd9\u6b3e\u5e94\u7528\u8fd8\u53ef\u4f9b\u6d4f\u89c8\u5176\u4ed6\u968f\u673a\u4f4d\u7f6e\u7684\u5929\u6c14\u72b6\u51b5\u3002<\/p>\n<p>\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u60a8\u5c06\u5b66\u4e60\u5982\u4f55\uff1a<\/p>\n<ul>\n<li>\u5728 PyCharm \u4e2d\u521b\u5efa Django \u9879\u76ee\u3002<\/li>\n<li>\u7f16\u5199\u6a21\u578b\u3001\u89c6\u56fe\u548c\u6a21\u677f\u3002<\/li>\n<li>\u8fdb\u884c API \u8c03\u7528\u5e76\u5904\u7406\u54cd\u5e94\u3002<\/li>\n<li>\u8fde\u63a5\u5230\u6570\u636e\u5e93\u5e76\u4f7f\u7528\u6570\u636e\u586b\u5145\u3002<\/li>\n<\/ul>\n<p>\u514b\u9686<a title=\"https:\/\/github.com\/denis-mashutin\/weather-app-tutorial\" href=\"https:\/\/github.com\/denis-mashutin\/weather-app-tutorial\" target=\"_blank\" rel=\"noreferrer noopener\">\u4ed3\u5e93<\/a>\u5373\u53ef\u83b7\u53d6\u5b8c\u6574\u7684\u5e94\u7528\u7a0b\u5e8f\u4ee3\u7801\u3002 \u8981\u4e86\u89e3\u6709\u5173\u514b\u9686\u7684\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605 <a href=\"https:\/\/www.jetbrains.com\/help\/pycharm\/cloning-repository.html\" target=\"_blank\" rel=\"noopener\">PyCharm \u6587\u6863<\/a>\u3002<\/p>\n<p><!--more--><\/p>\n<h2 class=\"wp-block-heading\">\u524d\u63d0<\/h2>\n<p>\u672c\u6559\u7a0b\u9002\u5408\u5df2\u7ecf\u6709\u6570\u5e74 Python \u7ecf\u9a8c\u7684\u5f00\u53d1\u8005\u3002 \u56e0\u6b64\uff0c\u6211\u4eec\u5047\u8bbe\u60a8\u7684\u7535\u8111\u4e0a\u5df2\u7ecf\u5b89\u88c5\u4e86 Python\u3002 \u5982\u679c\u4e0d\u662f\u8fd9\u6837\uff0c\u4e5f\u522b\u62c5\u5fc3\uff01 \u5f00\u59cb\u5728 PyCharm \u4e2d\u521b\u5efa\u7b2c\u4e00\u4e2a\u9879\u76ee\u65f6\uff0c\u60a8\u53ef\u4ee5\u4e0b\u8f7d\u5e76\u5b89\u88c5\u9700\u8981\u7684 Python \u7248\u672c\u3002<\/p>\n<p>\u5bf9 Django \u7684\u652f\u6301\u662f\u4e00\u9879\u4e13\u4e1a\u529f\u80fd\uff0c\u56e0\u6b64\u60a8\u9700\u8981 <a href=\"https:\/\/www.jetbrains.com.cn\/pycharm\/download\/\" target=\"_blank\" rel=\"noreferrer noopener\">PyCharm Professional<\/a>\u3002 \u65b0\u7528\u6237\u6709 30 \u5929\u7684\u514d\u8d39\u8bd5\u7528\u671f\uff0c\u5982\u679c\u60a8\u662f\u5b66\u751f\u6216\u6559\u5e08\uff0c\u53ef\u4ee5\u7533\u8bf7<a href=\"https:\/\/www.jetbrains.com.cn\/community\/education\/\" target=\"_blank\" rel=\"noreferrer noopener\">\u514d\u8d39\u6559\u80b2\u8bb8\u53ef\u8bc1<\/a>\u3002 \u672c\u6559\u7a0b\u57fa\u4e8e\u5df2\u542f\u7528<a href=\"https:\/\/www.jetbrains.com\/help\/pycharm\/2023.1\/new-ui.html\" target=\"_blank\" rel=\"noopener\">\u65b0 UI<\/a> \u7684 <strong>PyCharm 2023.1<\/strong>\u3002<\/p>\n<p>\u6709\u5173\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u7684\u66f4\u591a\u4fe1\u606f\u548c\u5b89\u88c5\u8bf4\u660e\uff0c\u8bf7\u53c2\u9605 <a href=\"https:\/\/www.jetbrains.com\/help\/pycharm\/installation-guide.html\" target=\"_blank\" rel=\"noopener\">PyCharm \u6587\u6863<\/a>\u3002<\/p>\n<h2 class=\"wp-block-heading\">\u5f00\u59cb\u6784\u5efa\u5e94\u7528<\/h2>\n<p>\u6211\u4eec\u5148\u8fc8\u51fa\u7b2c\u4e00\u6b65\u3002 \u6b65\u9aa4\u4e0d\u591a\uff0c\u6700\u540e\uff0c\u60a8\u5c06\u5f97\u5230\u4e00\u4e2a\u57fa\u7840\u5e94\u7528\u3002<\/p>\n<h3 class=\"wp-block-heading\">\u5728 PyCharm \u4e2d\u521b\u5efa Django \u9879\u76ee<\/h3>\n<p>\u8981\u521b\u5efa\u9879\u76ee\uff0c\u9996\u5148\u542f\u52a8 PyCharm \u5e76\u70b9\u51fb <strong>New Project<\/strong>\uff08\u65b0\u5efa\u9879\u76ee\uff09\u3002 \u5982\u679c PyCharm \u5df2\u7ecf\u5728\u8fd0\u884c\uff0c\u53ef\u4ee5\u4ece\u4e3b\u83dc\u5355\u4e2d\u9009\u62e9 <strong>File | New Project<\/strong>\uff08\u6587\u4ef6 | \u65b0\u5efa\u9879\u76ee\uff09\u3002<\/p>\n<p>\u5728\u6253\u5f00\u7684 <strong>New Project<\/strong>\uff08\u65b0\u5efa\u9879\u76ee\uff09\u7a97\u53e3\u4e2d\uff0c\u6307\u5b9a\u4ee5\u4e0b\u4fe1\u606f\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-334829\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/image-47.png\" alt=\"\u5728 PyCharm \u4e2d\u521b\u5efa Django \u9879\u76ee\" width=\"1600\" height=\"1300\" \/><\/figure>\n<\/div>\n<ol>\n<li>\u9009\u62e9 <strong>Django<\/strong> \u4f5c\u4e3a\u9879\u76ee\u7c7b\u578b\u3002<\/li>\n<li>\u8f93\u5165\u9879\u76ee\u6240\u5728\u76ee\u5f55\u7684\u540d\u79f0\u3002 \u8fd9\u4e5f\u5c06\u7528\u4f5c\u9879\u76ee\u540d\u79f0\u3002<\/li>\n<li>\u4e3a\u65b0 Django \u9879\u76ee\u521b\u5efa\u865a\u62df\u73af\u5883\uff0cPyCharm \u5c06\u5728\u5176\u4e2d\u5b89\u88c5\u4f9d\u8d56\u9879\u3002 \u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u9009\u62e9 <strong>virtualenv<\/strong> \u9009\u9879\u3002<\/li>\n<li>PyCharm \u53ef\u4ee5\u7acb\u5373\u5728\u9879\u76ee\u4e2d\u521b\u5efa Django \u5e94\u7528\u7a0b\u5e8f\u3002 \u52a1\u5fc5\u5728\u8fd9\u91cc\u4e3a\u5e94\u7528\u7a0b\u5e8f\u547d\u540d\u3002<\/li>\n<\/ol>\n<p>\u51c6\u5907\u597d\u540e\uff0c\u70b9\u51fb <strong>Create<\/strong>\uff08\u521b\u5efa\uff09\u3002 PyCharm \u521b\u5efa\u6587\u4ef6\u7ed3\u6784\uff0c\u5e76\u5b89\u88c5 Django \u548c\u5176\u4ed6\u9700\u8981\u7684\u4f9d\u8d56\u9879\u3002\u00a0<\/p>\n<p>\u70b9\u51fb\u7a97\u53e3\u9876\u90e8\u7684 <strong>Run<\/strong>\uff08\u8fd0\u884c\uff09\u56fe\u6807\u542f\u52a8 Django \u670d\u52a1\u5668\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-334851\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/run_for_the_first_time.png\" alt=\"\u8fd0\u884c Django \u670d\u52a1\u5668\" width=\"1956\" height=\"1328\" \/><\/figure>\n<\/div>\n<p>\u8fd9\u5c06\u6253\u5f00 <strong>Run<\/strong>\uff08\u8fd0\u884c\uff09\u5de5\u5177\u7a97\u53e3\u3002 \u70b9\u51fb\u94fe\u63a5\u6253\u5f00\u6d4f\u89c8\u5668\u7a97\u53e3\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-334885\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/django_server_running-1.png\" alt=\"\u6d4f\u89c8\u5668\u4e2d\u7684 Django \u670d\u52a1\u5668\u9875\u9762\" width=\"1980\" height=\"1194\" \/><\/figure>\n<\/div>\n<p>\u5728 PyCharm \u4e2d\u542f\u52a8 Django \u670d\u52a1\u5668\u53ea\u9700\u8981\u51e0\u5206\u949f\u7684\u65f6\u95f4\u3002 \u8fd9\u662f\u4e00\u4e2a\u597d\u7684\u5f00\u59cb\uff0c\u4f46\u6700\u597d\u7684\u8fd8\u5728\u524d\u9762\u3002<\/p>\n<h3 class=\"wp-block-heading\">\u7f16\u5199\u9996\u4e2a\u89c6\u56fe<\/h3>\n<p>\u73b0\u5728\uff0c\u5f00\u59cb\u521b\u5efa\u5e94\u7528\u7a0b\u5e8f\u903b\u8f91\u3002 \u5728 Django \u4e2d\uff0c\u5728 <strong>views.py<\/strong> \u4e2d\u7f16\u5199\u7c7b\u6216\u51fd\u6570\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u968f\u65f6\u70b9\u51fb PyCharm \u7a97\u53e3\u5de6\u4e0a\u89d2\u7684\u6587\u4ef6\u5939\u56fe\u6807\uff0c\u4e5f\u53ef\u4ee5\u6309 <strong>\u23181<\/strong> \/ <strong>Alt+1<\/strong> \u6765\u63a2\u7d22\u9879\u76ee\u7684\u7ed3\u6784\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-334873\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/project_tool_window.png\" alt=\"\u8bbf\u95ee Project\uff08\u9879\u76ee\uff09\u5de5\u5177\u7a97\u53e3\" width=\"363\" height=\"554\" \/><\/figure>\n<\/div>\n<p>\u672c\u6559\u7a0b\u5305\u542b\u53ef\u4ee5\u8282\u7701\u5927\u91cf\u65f6\u95f4\u7684\u5feb\u6377\u952e\uff0c\u4f8b\u5982\u6309\u4e24\u6b21 <strong>\u21e7 (Shift)<\/strong> \u952e\u53ef\u4ee5\u6253\u5f00 <strong>Search Everywhere<\/strong>\uff08\u968f\u5904\u641c\u7d22\uff09\u7a97\u53e3\u3002 \u8fd9\u4e2a\u5feb\u6377\u952e\u53ef\u4ee5\u627e\u5230\u4efb\u4f55\u5185\u5bb9\uff0c\u5305\u62ec\u9879\u76ee\u6587\u4ef6\u3001\u8bbe\u7f6e\u548c\u64cd\u4f5c\u3002<\/p>\n<p>\u6211\u4eec\u7528\u5b83\u6765\u5feb\u901f\u6253\u5f00 <strong>views.py<\/strong>\u3002<\/p>\n<p>\u8f93\u5165 <kbd>views<\/kbd>\uff0c\u5c06\u5149\u6807\u79fb\u52a8\u5230 <strong>meteo<\/strong> \u5904\u7684 <strong>views.py<\/strong>\uff0c\u7136\u540e\u6309 <strong>Enter<\/strong>\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-334897\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/find_views.png\" alt=\"\u4f7f\u7528 Search Everywhere\uff08\u968f\u5904\u641c\u7d22\uff09\" width=\"666\" height=\"243\" \/><\/figure>\n<\/div>\n<p>\u5e26\u6709 <strong>views.py<\/strong> \u7684\u7f16\u8f91\u5668\u6807\u7b7e\u9875\u968f\u5373\u6253\u5f00\u3002 \u6211\u4eec\u5148\u7f16\u5199\u4e00\u4e2a <code>temp_here<\/code> \u51fd\u6570\uff0c\u5b83\u5c06\u8fd4\u56de\u6211\u4eec\u4f4d\u7f6e\u7684\u5f53\u524d\u6e29\u5ea6\u3002\u00a0<\/p>\n<p>\u5728\u7f16\u8f91\u5668\u4e2d\u7c98\u8d34\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import requests\n\n\ndef temp_here():\n    location = geocoder.ip('me').latlng\n    endpoint = \"https:\/\/api.open-meteo.com\/v1\/forecast\"\n    api_request = f\"{endpoint}?latitude={location[0]}&amp;longitude={location[1]}&amp;hourly=temperature_2m\"\n    return requests.get(api_request).json()<\/pre>\n<p>\u8fd9\u91cc\u53d1\u751f\u4e86\u4ec0\u4e48\uff1f \u9996\u5148\uff0c\u5bfc\u5165 API \u8c03\u7528\u6240\u9700\u7684 <code>requests<\/code> \u5e93\u3002 \u5982\u679c import \u8bed\u53e5\u4e2d\u6709\u7ea2\u8272\u6ce2\u6d6a\u7ebf\uff0c\u5219\u8868\u793a\u8f6f\u4ef6\u5305\u5728\u6240\u9009 Python \u89e3\u91ca\u5668\u4e2d\u4e0d\u53ef\u7528\u3002<\/p>\n<p>\u5c06\u5149\u6807\u60ac\u505c\u5728\u5b83\u4e0a\u9762\uff0c\u9009\u62e9 <strong>Install package requests<\/strong>\uff08\u5b89\u88c5\u8f6f\u4ef6\u5305\u8bf7\u6c42\uff09\u3002<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-334980\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/install_requests.gif\" alt=\"\u5b89\u88c5\u8bf7\u6c42\u5e93\" width=\"875\" height=\"240\" \/><\/figure>\n<\/div>\n<p>\u4e3a\u4e86\u83b7\u53d6\u5f53\u524d\u6e29\u5ea6\uff0c<code>temp_here<\/code> \u4f1a\u8c03\u7528 <a href=\"https:\/\/open-meteo.com\/en\/docs\" target=\"_blank\" rel=\"noreferrer noopener\">Weather Forecast API<\/a>\u3002 \u8fd9\u662f\u4e00\u4e2a\u4e0d\u9700\u8981 API \u5bc6\u94a5\u7684\u514d\u8d39 API\u3002 \u6211\u4eec\u53ea\u9700\u8981\u77e5\u9053\u7aef\u70b9 (<a href=\"https:\/\/api.open-meteo.com\/v1\/forecast\" rel=\"nofollow noopener\" target=\"_blank\">https:\/\/api.open-meteo.com\/v1\/forecast<\/a>) \u548c\u5750\u6807\u3002 \u5bf9\u4e8e\u540e\u8005\uff0c\u6211\u4eec\u5c06\u4f7f\u7528 <a href=\"https:\/\/geocoder.readthedocs.io\/\" target=\"_blank\" rel=\"noreferrer noopener\">Geocoder<\/a> \u2013 \u8fd9\u662f\u4e00\u4e2a\u975e\u5e38\u7b80\u5355\u7684 Python \u5e93\uff0c\u53ef\u4f9b\u68c0\u7d22\u4e0d\u540c\u4f4d\u7f6e\u7684\u5750\u6807\u3002<\/p>\n<p>\u5c06\u6587\u672c\u5149\u6807\u653e\u5728\u4ee5\u7ea2\u8272\u6ce2\u6d6a\u7ebf\u9ad8\u4eae\u663e\u793a\u7684 <code>geocoder<\/code> \u4e0a\uff0c\u7136\u540e\u6309 <strong>\u2325Enter<\/strong> \/ <strong>Alt+Enter<\/strong> \u67e5\u770b\u53ef\u7528\u7684\u5feb\u901f\u4fee\u590d\u3002 \u9009\u62e9 <strong>Install and import package \u2018geocoder\u2019<\/strong>\uff08\u5b89\u88c5\u5e76\u5bfc\u5165\u8f6f\u4ef6\u5305 \u2018geocoder\u2019\uff09\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335005\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/install_geocoder.png\" alt=\"\u5b89\u88c5\u5e76\u5bfc\u5165 Python \u8f6f\u4ef6\u5305\" width=\"597\" height=\"274\" \/><\/figure>\n<\/div>\n<p>PyCharm \u4f1a\u5b89\u88c5\u8f6f\u4ef6\u5305\u5e76\u5c06 import \u8bed\u53e5\u6dfb\u52a0\u5230\u6587\u4ef6\u7684\u5f00\u5934\u3002<\/p>\n<p>\u90a3\u4e48\uff0c\u5982\u4f55\u53d1\u51fa\u6d4b\u8bd5\u8bf7\u6c42\u6765\u786e\u4fdd\u4e00\u5207\u6309\u9884\u671f\u5de5\u4f5c\uff1f \u6700\u7b80\u5355\u7684\u65b9\u5f0f\u662f\u5728 Python \u63a7\u5236\u53f0\u4e2d\u8c03\u7528\u51fd\u6570\u3002<\/p>\n<p>\u6211\u4eec\u6765\u4f7f\u7528\u53e6\u4e00\u4e2a\u8282\u7701\u65f6\u95f4\u7684\u65b9\u5f0f \u2013 <strong>Find action<\/strong>\uff08\u67e5\u627e\u64cd\u4f5c\uff09\u3002 \u4e0d\u7528\u5728\u83dc\u5355\u4e2d\u6ed1\u52a8\u9f20\u6807\uff0c\u4e5f\u4e0d\u7528\u80cc\u4e0b\u51e0\u5341\u4e2a\u5feb\u6377\u952e\uff0c\u53ea\u9700\u6309 <strong>\u21e7\u2318A<\/strong> \/ <strong>Ctrl+Shift+A<\/strong>\uff0c\u7136\u540e\u641c\u7d22 <strong>Run File in Python Console<\/strong>\uff08\u5728 Python \u63a7\u5236\u53f0\u4e2d\u8fd0\u884c\u6587\u4ef6\uff09\u3002<\/p>\n<p>\u60a8\u4e0d\u9700\u8981\u6253\u51fa\u6574\u4e2a\u5355\u8bcd\u3002 \u4f7f\u7528 <kbd>rufipy<\/kbd> \u8fd9\u6837\u7684\u8bcd\u4e5f\u4f1a\u5f97\u5230\u60f3\u8981\u7684\u7ed3\u679c\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335016\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/rufipy.png\" alt=\"\" width=\"670\" height=\"174\" \/><\/figure>\n<\/div>\n<p>\u8fd0\u884c\u547d\u4ee4\u65f6\uff0cPyCharm \u4f1a\u5c06 import \u548c\u51fd\u6570\u5b9a\u4e49\u52a0\u8f7d\u5230\u63a7\u5236\u53f0\u4e2d\u3002 \u73b0\u5728\uff0c\u8c03\u7528 <code>temp_here<\/code>\u3002 \u6309 <strong>Tab<\/strong> \u952e\u53ef\u4ee5\u8865\u5168\u4ee3\u7801\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335028\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/autocompletion_python_console.png\" alt=\"\u5728 Python \u63a7\u5236\u53f0\u4e2d\u4f7f\u7528\u4ee3\u7801\u8865\u5168\" width=\"708\" height=\"285\" \/><\/figure>\n<\/div>\n<p>\u68c0\u67e5\u6765\u81ea\u63a7\u5236\u53f0\u8f93\u51fa\u7684 API \u54cd\u5e94\u3002 \u8fd9\u4e2a\u5b57\u7b26\u4e32\u5f88\u957f\uff0c\u4f46\u4e0b\u9762\u6709\u8bf4\u660e\u6027\u8868\u793a\u3002<\/p>\n<p>\u5982\u679c\u8981\u63a2\u7d22\u54cd\u5e94\uff0c\u53ef\u4ee5\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li>\u70b9\u51fb 3 \u6b21\u63a7\u5236\u53f0\u8f93\u51fa\uff0c\u7136\u540e\u6309 <strong>\u2318C<\/strong> \/ <strong>Ctrl+C<\/strong> \u5c06\u5176\u590d\u5236\u5230\u526a\u8d34\u677f\u3002<\/li>\n<li>\u6309 <strong>\u21e7\u2318N<\/strong> \/ <strong>Ctrl+Alt+Shift+Insert<\/strong> \u521b\u5efa\u4e34\u65f6\u6587\u4ef6\uff0c\u7136\u540e\u9009\u62e9 <strong>JSON<\/strong> \u6587\u4ef6\u7c7b\u578b\uff08\u8f93\u5165 <kbd>js\u2026<\/kbd> \u5373\u53ef\uff09\u3002<\/li>\n<li>\u7c98\u8d34\u54cd\u5e94\u5e76\u5e94\u7528 <strong>Reformat Code<\/strong>\uff08\u91cd\u65b0\u683c\u5f0f\u5316\u4ee3\u7801\uff09\u64cd\u4f5c\u3002 \u53ef\u4ee5\u4f7f\u7528 <strong>Find action<\/strong>\uff08\u67e5\u627e\u64cd\u4f5c\uff09\u6216\u6309 <strong>\u2325\u2318L<\/strong> \/ <strong>Ctrl+Alt+L<\/strong>\u3002<\/li>\n<\/ol>\n<p>\u6240\u9700\u4fe1\u606f\u4f4d\u4e8e <code>temperature_2m<\/code> \u952e\u4e0b\u7684 <code>hourly<\/code> \u5143\u7d20\u4e2d\u3002 \u6b64\u952e\u6307\u5411\u4e00\u4e2a\u503c\u5217\u8868\u3002<\/p>\n<p>\u4e3a\u4e86\u83b7\u53d6\u5f53\u524d\u6e29\u5ea6\uff0c\u6211\u4eec\u5fc5\u987b\u5c06\u5f53\u524d\u5c0f\u65f6\u4f5c\u4e3a\u7d22\u5f15\u3002 \u4f8b\u5982\uff0c\u5982\u679c\u73b0\u5728\u662f 14:30\uff0c\u6211\u4eec\u5c06\u4f7f\u7528\u5217\u8868\u7684\u7b2c 14 \u9879\u3002<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335039\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/api_response_explained.png\" alt=\"\u63a2\u7d22 API \u54cd\u5e94\" width=\"800\" height=\"637\" \/><\/figure>\n<\/div>\n<p>\u770b\u4e00\u4e0b <code>temp_here()['hourly']['temperature_2m'][14]<\/code> \u662f\u5426\u63d0\u4f9b\u4e86\u9700\u8981\u7684\u4fe1\u606f\u3002<\/p>\n<p>\u6839\u636e\u5f53\u524d\u65f6\u95f4\u66ff\u6362 <kbd>14<\/kbd>\uff0c\u5e76\u5728\u63a7\u5236\u53f0\u4e2d\u8f93\u5165\u4ee3\u7801\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335061\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/manual_request_console.png\" alt=\"\u4ece Python \u63a7\u5236\u53f0\u5411 API \u53d1\u9001\u8bf7\u6c42\" width=\"574\" height=\"270\" \/><\/figure>\n<\/div>\n<p>14.9 \u00b0C \u662f\u6211\u4eec\u6240\u5728\u4f4d\u7f6e\u7684\u5f53\u524d\u6e29\u5ea6\u3002 \u60a8\u90a3\u91cc\u5462\uff1f<\/p>\n<p>\u4fee\u6539\u51fd\u6570\uff0c\u8ba9\u5b83\u4ece API \u54cd\u5e94\u4e2d\u63d0\u53d6\u5f53\u524d\u6e29\u5ea6\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"5-9\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">def temp_here():\n    location = geocoder.ip('me').latlng\n    endpoint = \"https:\/\/api.open-meteo.com\/v1\/forecast\"\n    api_request = f\"{endpoint}?latitude={location[0]}&amp;longitude={location[1]}&amp;hourly=temperature_2m\"\n    now = datetime.now()\n    hour = now.hour\n    meteo_data = requests.get(api_request).json()\n    temp = meteo_data['hourly']['temperature_2m'][hour]\n    return temp<\/pre>\n<p>\u8bb0\u5f97\u5bfc\u5165 <code>datetime<\/code>\uff1a<\/p>\n<figure class=\"wp-block-video aligncenter\"><video src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/import_datetime.mp4\" controls=\"controls\" width=\"300\" height=\"150\"><\/video><\/figure>\n<p>\u70b9\u51fb Python \u63a7\u5236\u53f0\u5de5\u5177\u680f\u5de6\u4e0a\u89d2\u7684 <strong>Rerun<\/strong>\uff08\u91cd\u65b0\u8fd0\u884c\uff09\uff0c\u91cd\u65b0\u52a0\u8f7d\u66f4\u65b0\u7684\u51fd\u6570\u5b9a\u4e49\uff0c\u7136\u540e\u518d\u6b21\u8c03\u7528 <code>temp_here<\/code>\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335092\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/rerun_same_result.png\" alt=\"\u4ece Python \u63a7\u5236\u53f0\u8c03\u7528\u66f4\u65b0\u7684\u51fd\u6570\" width=\"687\" height=\"222\" \/><\/figure>\n<\/div>\n<p>\u5982\u679c\u7ed3\u679c\u4e0e\u66f4\u6539 <code>temp_here<\/code> \u51fd\u6570\u4ee3\u7801\u4e4b\u524d\u7684\u7ed3\u679c\u4e0d\u540c\uff0c\u90a3\u53ef\u80fd\u662f\u56e0\u4e3a <strong>settings.py<\/strong> \u4e2d\u7684 <code>TIME_ZONE<\/code> \u503c\u9519\u8bef\u3002\u00a0<\/p>\n<p>\u6709\u5173\u8be6\u60c5\uff0c\u8bf7\u53c2\u9605 <a href=\"https:\/\/docs.djangoproject.com\/en\/4.1\/ref\/settings\/#std-setting-TIME_ZONE\" target=\"_blank\" rel=\"noreferrer noopener\">Django \u6587\u6863<\/a>\u3002<\/p>\n<p>\u8981\u5feb\u901f\u8bbf\u95ee\u6b64\u8bbe\u7f6e\uff0c\u9996\u5148\u6309\u4e24\u6b21 <strong>\u21e7 (Shift)<\/strong>\uff0c\u6309\u51e0\u6b21 <strong>Tab<\/strong> \u5207\u6362\u5230 <strong>Symbols<\/strong>\uff08\u7b26\u53f7\uff09\uff0c\u7136\u540e\u8f93\u5165 <kbd>time\u2026<\/kbd>\u3002<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335103\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/time_zone_settings.png\" alt=\"\u4f7f\u7528 Search Everywhere\uff08\u968f\u5904\u641c\u7d22\uff09\u641c\u7d22\u8bbe\u7f6e\" width=\"681\" height=\"267\" \/><\/figure>\n<\/div>\n<p>\u63a5\u4e0b\u6765\uff0c\u5c06 <code>temp_here<\/code> \u53d8\u6210\u89c6\u56fe\u51fd\u6570\u3002 \u8981\u88ab Django \u8bc6\u522b\u4e3a\u89c6\u56fe\uff0c\u51fd\u6570\u5fc5\u987b\u63a5\u53d7 <strong>HttpRequest<\/strong> \u5bf9\u8c61\u4f5c\u4e3a\u5176\u7b2c\u4e00\u4e2a\u5f62\u53c2\uff0c\u901a\u5e38\u547d\u540d\u4e3a <code>request<\/code>\u3002 \u5b83\u8fd8\u5e94\u8be5\u8fd4\u56de <strong>HttpResponse<\/strong> \u5bf9\u8c61\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f <strong>views.py<\/strong> \u7684\u6837\u5b50\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"8,16\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">from datetime import datetime\n\nimport geocoder as geocoder\nimport requests\nfrom django.http import HttpResponse\n\n\ndef temp_here(request):\n    location = geocoder.ip('me').latlng\n    endpoint = \"https:\/\/api.open-meteo.com\/v1\/forecast\"\n    api_request = f\"{endpoint}?latitude={location[0]}&amp;longitude={location[1]}&amp;hourly=temperature_2m\"\n    now = datetime.now()\n    hour = now.hour\n    meteo_data = requests.get(api_request).json()\n    temp = meteo_data['hourly']['temperature_2m'][hour]\n    return HttpResponse(f\"Here it's {temp}\")<\/pre>\n<p>\u5982\u60a8\u6240\u89c1\uff0c\u6211\u4eec\u6ca1\u6709\u505a\u592a\u591a\u66f4\u6539\uff1a<code>temp_here<\/code> \u73b0\u5728\u63a5\u53d7 <code>request<\/code> \u4f5c\u4e3a\u5b9e\u53c2\u5e76\u8fd4\u56de\u5e26\u6709\u5b57\u7b26\u4e32\u7684 <code>HttpResponse<\/code>\u3002<\/p>\n<p>\u5982\u679c\u60a8\u504f\u597d\u534e\u6c0f\u5ea6\u800c\u4e0d\u662f\u6444\u6c0f\u5ea6\uff0c\u8fd9\u5f88\u5bb9\u6613\u5b9e\u73b0\uff0c\u53ea\u9700\u5c06 <code>temperature_unit<\/code> \u5f62\u53c2\u6dfb\u52a0\u5230 API \u8bf7\u6c42\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">api_request = f\"{endpoint}?latitude={location[0]}&amp;longitude={location[1]}&amp;hourly=temperature_2m&amp;temperature_unit=fahrenheit\"<\/pre>\n<p>\u5982\u679c\u60a8\u66f4\u559c\u6b22\u4f7f\u7528\u6444\u6c0f\u5ea6\uff0c\u5219\u8df3\u8fc7\u6b64\u4fee\u6539\u3002<\/p>\n<h3 class=\"wp-block-heading\">\u914d\u7f6e URL<\/h3>\n<p>\u66f4\u65b0 <strong>urls.py<\/strong>\uff0c\u914d\u7f6e\u4ece\u6d4f\u89c8\u5668\u8bbf\u95ee\u5e94\u7528\u7684\u65b9\u5f0f\u3002 \u6309\u4e24\u6b21 <strong>Shift<\/strong>\uff0c\u8f93\u5165 urls\uff0c\u5982\u4e0a\u6240\u8ff0\u67e5\u627e\u548c\u6253\u5f00\u3002<\/p>\n<p>\u5c06\u4ee5\u4e0b\u884c\u6dfb\u52a0\u5230 <code>urlpatterns<\/code>\u3002 \u4f7f\u7528 <strong>Reformat Code<\/strong>\uff08\u91cd\u65b0\u683c\u5f0f\u5316\u4ee3\u7801\uff09\u64cd\u4f5c <strong>\u2325\u2318L<\/strong> \/ <strong>Ctrl+Alt+L<\/strong> \u53ef\u4ee5\u5728\u7c98\u8d34\u540e\u8f7b\u677e\u8fd8\u539f\u7f29\u8fdb\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">path(\"\", include('meteo.urls')),<\/pre>\n<p>\u4e0d\u8981\u5fd8\u8bb0\u4ece <code>django.urls.include<\/code> \u5bfc\u5165 <code>include<\/code>\u3002<\/p>\n<p><code>'meteo.urls'<\/code> \u73b0\u5728\u88ab\u6807\u8bb0\u4e3a\u5e26\u6709\u9ec4\u8272\u6ce2\u6d6a\u7ebf\u7684\u672a\u89e3\u6790\u5f15\u7528\uff0c\u56e0\u4e3a\u6587\u4ef6\u5c1a\u4e0d\u5b58\u5728\u3002 \u8fd9\u5c06\u5728\u540e\u7eed\u6b65\u9aa4\u4e2d\u5f97\u5230\u4fee\u6b63\u3002<\/p>\n<p>Django \u9879\u76ee\u901a\u5e38\u5305\u542b\u591a\u4e2a\u5e94\u7528\u3002 \u5373\u4f7f\u76ee\u524d\u5e76\u975e\u5982\u6b64\uff0c\u4e5f\u8981\u8003\u8651\u9879\u76ee\u7684\u672a\u6765\u53d1\u5c55\u3002 \u56e0\u6b64\uff0c\u6211\u4eec\u5728\u5bf9\u5e94\u6587\u4ef6\u5939\u4e2d\u4e3a\u6bcf\u4e2a\u5e94\u7528\u7a0b\u5e8f\u521b\u5efa <strong>urls.py<\/strong> \uff0c\u7136\u540e\u5c06\u5b83\u4eec\u5168\u90e8\u6dfb\u52a0\u5230\u9879\u76ee\u7684 <strong>urls.py<\/strong> \u4e2d\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u5728 <strong>meteo<\/strong> \u5e94\u7528\u7a0b\u5e8f\u7684\u6587\u4ef6\u5939\u4e2d\u521b\u5efa <strong>urls.py<\/strong>\u3002<\/p>\n<p>\u5728 <strong>Project<\/strong>\uff08\u9879\u76ee\uff09\u5de5\u5177\u7a97\u53e3\u4e2d\u53f3\u952e\u70b9\u51fb <strong>meteo<\/strong> \u76ee\u5f55\u3002<\/p>\n<p>\u9009\u62e9 <strong>New &gt; Python File<\/strong>\uff08\u65b0\u5efa &gt; Python \u6587\u4ef6\uff09\uff0c\u8f93\u5165 <kbd>urls<\/kbd>\u3002<\/p>\n<p>\u65b0\u521b\u5efa\u7684\u6587\u4ef6\u5c06\u6253\u5f00\u3002 \u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u586b\u5145\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">from django.urls import path\nfrom . import views\n\n\nurlpatterns = [\n    path('meteo\/', views.temp_here, name='temp_here'),\n]<\/pre>\n<p>\u73b0\u5728\uff0c\u5f53\u6211\u4eec\u5728\u6d4f\u89c8\u5668\u4e2d\u8f6c\u5230 <kbd>&lt;server_address&gt;\/meteo<\/kbd> \u65f6\uff0c<strong>views.py<\/strong> \u4e2d\u7684 <code>temp_here<\/code> \u51fd\u6570\u5c06\u88ab\u8c03\u7528\uff0c\u6d4f\u89c8\u5668\u5c06\u6e32\u67d3\u51fd\u6570\u8fd4\u56de\u7684\u4efb\u4f55\u5185\u5bb9\u3002<\/p>\n<h3 class=\"wp-block-heading\">\u5b83\u4e0a\u7ebf\u4e86\uff01<\/h3>\n<p>\u70b9\u51fb\u53f3\u4e0a\u89d2\u7684 <strong>Rerun<\/strong>\uff08\u91cd\u65b0\u8fd0\u884c\uff09\u6309\u94ae\u91cd\u65b0\u8fd0\u884c Django \u670d\u52a1\u5668\u5e76\u786e\u8ba4\u64cd\u4f5c\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335121\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/stop_and_rerun.png\" alt=\"\u91cd\u65b0\u8fd0\u884c Django \u670d\u52a1\u5668\" width=\"844\" height=\"397\" \/><\/figure>\n<\/div>\n<p>\u5728\u6d4f\u89c8\u5668\u4e2d\u6253\u5f00 <a href=\"http:\/\/127.0.0.1:8000\/meteo\/\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/127.0.0.1:8000\/meteo\/<\/a>\u3002 \u60a8\u770b\u5230\u7684\u5185\u5bb9\u5e94\u8be5\u7c7b\u4f3c\u4e8e\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335132\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/image-49.png\" alt=\"\u6d4f\u89c8\u5668\u4e2d\u7684\u5e94\u7528\u7a0b\u5e8f\u9875\u9762\" width=\"410\" height=\"207\" \/><\/figure>\n<\/div>\n<p>\u5982\u679c\u60a8\u4e0d\u60f3\u5728\u6bcf\u6b21\u91cd\u65b0\u542f\u52a8 Django \u670d\u52a1\u5668\u65f6\u6253\u5f00\u6d4f\u89c8\u5668\u8f93\u5165\u5730\u5740\uff0c\u6216\u624b\u52a8\u5237\u65b0\u9875\u9762\uff0c\u53ef\u4ee5\u5c06 PyCharm \u914d\u7f6e\u4e3a\u4ee3\u60a8\u5b8c\u6210\u8fd9\u4e9b\u64cd\u4f5c\u3002<\/p>\n<p>\u6253\u5f00 <strong>Run<\/strong>\uff08\u8fd0\u884c\uff09\u5fae\u4ef6\u4e2d\u7684\u4e0b\u62c9\u83dc\u5355\uff0c\u9009\u62e9 <strong>Edit configurations<\/strong>\uff08\u7f16\u8f91\u914d\u7f6e\uff09\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335143\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/edit_confiurations.png\" alt=\"\u7f16\u8f91\u8fd0\u884c\u914d\u7f6e\" width=\"265\" height=\"215\" \/><\/figure>\n<\/div>\n<p>\u5728\u5de6\u7a97\u683c\u4e2d\u9009\u62e9\u9879\u76ee\u7684\u914d\u7f6e\uff0c\u542f\u7528 <strong>Run browser<\/strong>\uff08\u8fd0\u884c\u6d4f\u89c8\u5668\uff09\u590d\u9009\u6846\uff0c\u7136\u540e\u5c06 <kbd>meteo<\/kbd> \u6dfb\u52a0\u5230 url\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335154\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/run_browser.png\" alt=\"\u914d\u7f6e URL\" width=\"1040\" height=\"676\" \/><\/figure>\n<\/div>\n<p>\u70b9\u51fb <strong>OK<\/strong>\uff08\u786e\u5b9a\uff09\u5e94\u7528\u66f4\u6539\u3002<\/p>\n<p>\u57fa\u672c\u4e0a\uff0c\u5e94\u7528\u5df2\u7ecf\u53ef\u4ee5\u8fd0\u884c\u4e86\u3002 \u4f46\u5b83\u5728\u6d4f\u89c8\u5668\u4e2d\u4e0d\u592a\u597d\u770b\uff0c\u800c\u4e14\u4ecd\u7136\u6ca1\u6709\u201c\u968f\u673a\u4f4d\u7f6e\u5929\u6c14\u201d\u529f\u80fd\u3002 \u5728\u63a5\u4e0b\u6765\u7684\u6b65\u9aa4\u4e2d\uff0c\u6211\u4eec\u5c06\u5f15\u5165\u6a21\u677f\u5e76\u5bfc\u5165\u6570\u636e\u6765\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\u3002<\/p>\n<h2 class=\"wp-block-heading\">\u6539\u8fdb\u4f53\u9a8c<\/h2>\n<h3 class=\"wp-block-heading\">\u6dfb\u52a0\u6a21\u677f<\/h3>\n<p>\u6211\u4eec\u56de\u5230 <strong>views.py<\/strong>\uff0c\u518d\u6b21\u4fee\u6539 <code>temp_here<\/code> \u51fd\u6570\u3002 \u5982\u679c\u60a8\u8fd8\u5728 <strong>meteo\/urls.py<\/strong> \u4e2d\uff0c\u53ef\u4ee5\u7acb\u5373\u5bfc\u822a\u5230\u90a3\u91cc\u3002 \u6309\u4f4f <strong>\u2318<\/strong> \/ <strong>Ctrl<\/strong>\uff0c\u5c06\u9f20\u6807\u60ac\u505c\u5728 <code>temp_here<\/code> \u4e0a\uff0c\u5f53\u5b83\u53d8\u6210\u8d85\u94fe\u63a5\u65f6\u70b9\u51fb\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335165\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/go_to_temp_here_from_urls-1.gif\" alt=\"\u5bfc\u822a\u5230\u51fd\u6570\u5b9a\u4e49\" width=\"640\" height=\"480\" \/><\/figure>\n<\/div>\n<p>\u5728 return \u8bed\u53e5\u4e4b\u524d\u5f00\u59cb\u4e00\u4e2a\u65b0\u884c\u5e76\u8f93\u5165\u201ctemplate = loader\u201d\u3002<\/p>\n<p>\u6309 <strong>\u2325Enter<\/strong>\/ <strong>Alt+Enter<\/strong> \u5e76\u4f7f\u7528\u5feb\u901f\u4fee\u590d\u4ece <code>django.template.loader<\/code> \u5bfc\u5165 <code>loader<\/code>\uff1a<\/p>\n<figure class=\"wp-block-video aligncenter\"><video src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/import_loader.mp4\" controls=\"controls\" width=\"300\" height=\"150\"><\/video><\/figure>\n<p>\u7136\u540e\uff0c\u4f7f\u7528 <code>get_template()<\/code> \u52a0\u8f7d <strong>index.html<\/strong> \u4f5c\u4e3a\u6a21\u677f\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    template = loader.get_template('index.html')<\/pre>\n<p>\u73b0\u5728\uff0c\u5c06 return \u8bed\u53e5\u66ff\u6362\u4e3a\u4ee5\u4e0b\u4e24\u884c\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    context = {'temp': temp}\n    return HttpResponse(template.render(context, request))<\/pre>\n<p><strong>Index.html<\/strong> \u4ee5\u9ec4\u8272\u6ce2\u6d6a\u7ebf\u9ad8\u4eae\u663e\u793a\uff0c\u56e0\u4e3a\u5b83\u5c1a\u4e0d\u5b58\u5728\u3002 \u5c06\u5149\u6807\u60ac\u505c\u5728\u5b83\u4e0a\u9762\u5e76\u9009\u62e9 <strong>Create template index.html<\/strong>\uff08\u521b\u5efa\u6a21\u677f index.html\uff09\u3002<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335187\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/create_template.png\" alt=\"\u521b\u5efa\u6a21\u677f\u6587\u4ef6\" width=\"550\" height=\"148\" \/><\/figure>\n<\/div>\n<p>\u70b9\u51fb <strong>OK<\/strong>\uff08\u786e\u5b9a\uff09\u3002 PyCharm \u5c06\u521b\u5efa <strong>index.html<\/strong> \u5e76\u6253\u5f00\u5b83\u8fdb\u884c\u7f16\u8f91\u3002<\/p>\n<p>\u6587\u4ef6\u73b0\u5728\u4e3a\u7a7a\u3002 \u4f7f\u7528 <strong>Live Template<\/strong>\uff08\u5b9e\u65f6\u6a21\u677f\uff09\u586b\u5145\u6a21\u677f html \u4ee3\u7801\u3002 \u8f93\u5165 <kbd>html:5<\/kbd>\uff0c\u6309 <strong>Tab<\/strong>\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335198\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/html_live_template.gif\" alt=\"\u4f7f\u7528\u5b9e\u65f6\u6a21\u677f\" width=\"893\" height=\"359\" \/><\/figure>\n<\/div>\n<p>html \u9875\u9762\u7684\u53ef\u89c1\u5185\u5bb9\u4f4d\u4e8e <code>&lt;body&gt;&lt;\/body&gt;<\/code> \u6807\u8bb0\u4e4b\u95f4\u3002\u00a0<\/p>\n<p>\u5728\u8fd9\u91cc\u63d2\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;h1&gt;Temperature at your location:&lt;\/h1&gt;\n&lt;h2&gt;{{ temp }} \u2103&lt;\/h2&gt;<\/pre>\n<p><code>temp<\/code> \u662f\u4ece\u89c6\u56fe\u4f20\u9012\u7ed9\u6a21\u677f\u7684\u53d8\u91cf\u3002 \u53d8\u91cf\u7684\u540d\u79f0\u548c\u503c\u5e94\u4fdd\u5b58\u5230\u5b57\u5178\u4e2d\uff0c\u5e76\u5728\u6e32\u67d3\u6a21\u677f\u65f6\u4f20\u9012\u3002 \u4e3a\u6b64\uff0c\u6211\u4eec\u5c06 <code>{\u2018temp\u2019 : temp}<\/code> \u8d4b\u7ed9\u4ee5\u4e0a <strong>views.py<\/strong> \u4e2d\u7684\u4e0a\u4e0b\u6587\u53d8\u91cf\u3002\u00a0<\/p>\n<p>\u6444\u6c0f\u5ea6\u7b26\u53f7\u7684 Unicode \u8868\u793a\u662f <code>&amp;#8451<\/code>\u3002 \u534e\u6c0f\u5ea6\u4f7f\u7528 <code>&amp;#8457<\/code>\u3002\u00a0<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u91cd\u65b0\u8fd0\u884c Django \u670d\u52a1\u5668\u67e5\u770b\u66f4\u6539\uff0c\u5e76\u786e\u4fdd\u5e94\u7528\u6309\u9884\u671f\u5de5\u4f5c\u3002 \u5982\u679c\u60a8\u5df2\u6309\u4e0a\u8ff0\u8bf4\u660e\u7f16\u8f91\u4e86\u8fd0\u884c\u914d\u7f6e\uff0c\u6d4f\u89c8\u5668\u7a97\u53e3\u5e94\u81ea\u52a8\u6253\u5f00\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335209\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/image-50.png\" alt=\"\u4ece\u6a21\u677f\u751f\u6210\u7684\u5e94\u7528\u7a0b\u5e8f\u9875\u9762\" width=\"448\" height=\"178\" \/><\/figure>\n<\/div>\n<h3 class=\"wp-block-heading\">\u521b\u5efa\u6570\u636e\u5e93\u548c\u6a21\u578b<\/h3>\n<p>\u4e3a\u4e86\u4ece API \u83b7\u53d6\u968f\u673a\u4f4d\u7f6e\u7684\u6e29\u5ea6\u6570\u636e\uff0c\u6211\u4eec\u9700\u8981\u63d0\u4f9b\u8fd9\u4e9b\u4f4d\u7f6e\u7684\u5750\u6807\u3002<\/p>\n<p>\u4e3a\u6b64\uff0c\u4f7f\u7528 <a href=\"https:\/\/www.kaggle.com\/juanmah\" target=\"_blank\" rel=\"noreferrer noopener\">Juanma Hern\u00e1ndez<\/a> \u5728 <a href=\"https:\/\/creativecommons.org\/licenses\/by\/4.0\/\" target=\"_blank\" rel=\"noreferrer noopener\">CC BY 4.0<\/a> \u8bb8\u53ef\u4e0b\u63d0\u4f9b\u7684 <a href=\"https:\/\/www.kaggle.com\/datasets\/juanmah\/world-cities\" target=\"_blank\" rel=\"noopener\">World cities<\/a> <a href=\"https:\/\/www.kaggle.com\/datasets\/juanmah\/world-cities\" target=\"_blank\" rel=\"noreferrer noopener\">\u6570\u636e\u5e93<\/a>\u3002 \u4e0b\u8f7d\u6570\u636e\u5e93\u5e76\u4ece\u5f52\u6863\u63d0\u53d6 <strong>worldcities.csv<\/strong>\u3002 \u5982\u679c\u60a8\u5728 <a href=\"https:\/\/www.kaggle.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Kaggle<\/a> \u8fd8\u6ca1\u6709\u5e10\u6237\uff0c\u5219\u5fc5\u987b\u6ce8\u518c\u3002<\/p>\n<p>\u6211\u4eec\u8fd8\u9700\u8981\u5c06 Django \u81ea\u52a8\u521b\u5efa\u7684 <strong>db.sqlite3<\/strong> \u6570\u636e\u5e93\u6dfb\u52a0\u5230\u6211\u4eec\u7684 PyCharm \u9879\u76ee\u3002<\/p>\n<p>\u4e3a\u6b64\uff1a<\/p>\n<ol>\n<li>\u70b9\u51fb\u53f3\u4fa7\u7684\u6570\u636e\u5e93\u56fe\u6807\u6253\u5f00 <strong>Database<\/strong>\uff08\u6570\u636e\u5e93\uff09\u5de5\u5177\u7a97\u53e3\u3002 \u60a8\u4e5f\u53ef\u4ee5\u6309 <strong>\u2318E<\/strong> \/<strong> Ctrl+E<\/strong> \u8bbf\u95ee\u6240\u6709\u5de5\u5177\u7a97\u53e3\uff1a<\/li>\n<\/ol>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335243\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/open_database_tool_window.png\" alt=\"\u8bbf\u95ee Database\uff08\u6570\u636e\u5e93\uff09\u5de5\u5177\u7a97\u53e3\" width=\"500\" height=\"392\" \/><\/figure>\n<\/div>\n<ol start=\"2\">\n<li>\u70b9\u51fb\u5de5\u5177\u7a97\u53e3\u5de6\u4e0a\u89d2\u7684 <strong>+<\/strong>\uff0c\u9009\u62e9 <strong>Data Source &gt; SQLite<\/strong>\uff08\u6570\u636e\u6e90 &gt; SQLite\uff09\u3002 \u8f93\u5165 <kbd>sq\u2026<\/kbd> \u53ef\u4ee5\u66f4\u5feb\u5730\u627e\u5230\u6240\u9700\u9009\u9879\uff1a<\/li>\n<\/ol>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335257\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/create_sql_source.png\" alt=\"\u521b\u5efa SQL Lite \u6570\u636e\u6e90\" width=\"509\" height=\"327\" \/><\/figure>\n<\/div>\n<ol start=\"3\">\n<li>\u70b9\u51fb <strong>File<\/strong>\uff08\u6587\u4ef6\uff09\u5b57\u6bb5\u65c1\u8fb9\u7684 <strong>\u2026<\/strong>\uff0c\u5728\u9879\u76ee\u6587\u4ef6\u5939\u4e2d\u67e5\u627e <strong>db.sqlite3<\/strong> \u6587\u4ef6\u3002<\/li>\n<li>\u60a8\u53ef\u80fd\u9700\u8981\u5b89\u88c5\u3001\u66f4\u65b0\u6216\u5207\u6362\u6570\u636e\u5e93\u9a71\u52a8\u7a0b\u5e8f\u3002 \u5982\u679c\u7a97\u53e3\u5e95\u90e8\u51fa\u73b0\u8b66\u544a\uff0c\u5219\u70b9\u51fb\u94fe\u63a5\u6267\u884c\u6240\u9700\u64cd\u4f5c\uff1a<\/li>\n<\/ol>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335270\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/image-51.png\" alt=\"\u5b89\u88c5\/\u5207\u6362\u6570\u636e\u5e93\u9a71\u52a8\u7a0b\u5e8f\" width=\"800\" height=\"676\" \/><\/figure>\n<\/div>\n<ol start=\"5\">\n<li>\u70b9\u51fb <strong>OK<\/strong>\uff08\u786e\u5b9a\uff09\u3002<\/li>\n<\/ol>\n<p>\u4e3a\u4e86\u5c06\u6570\u636e\u5bfc\u5165\u6570\u636e\u5e93\uff0c\u5e94\u5728 <strong>Database<\/strong>\uff08\u6570\u636e\u5e93\uff09\u5de5\u5177\u7a97\u53e3\u4e2d\u5c06 <strong>worldcities.csv<\/strong> \u62d6\u653e\u5230 <strong>db.sqlite3<\/strong>\u3002 \u5728\u6253\u5f00\u7684\u5bf9\u8bdd\u6846\u4e2d\uff0c\u79fb\u9664\u4e0d\u5fc5\u8981\u7684\u5217\uff0c\u53ea\u4fdd\u7559 <strong>city\u3001lat\u3001lng\u3001country<\/strong> \u548c <strong>id<\/strong>\uff1a<\/p>\n<figure class=\"wp-block-video aligncenter\"><video src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/dnd_csv_to_db.mp4\" controls=\"controls\" width=\"300\" height=\"150\"><\/video><\/figure>\n<p>\u73b0\u5728\uff0c<strong>db.sqlite3<\/strong> \u6570\u636e\u5e93\u5305\u542b <strong>worldcities<\/strong> \u8868\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335292\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/worldcities_table_in_db.png\" alt=\"\u6570\u636e\u5e93\u7ed3\u6784\u4e2d\u7684 Worldcities \u8868\" width=\"457\" height=\"180\" \/><\/figure>\n<\/div>\n<p>\u53cc\u51fb\u5373\u53ef\u5728\u7f16\u8f91\u5668\u4e2d\u67e5\u770b\u5176\u5185\u5bb9\u3002<\/p>\n<p>Django \u4f7f\u7528\u6a21\u578b\u4e0e\u6570\u636e\u5e93\u4ea4\u4e92\u3002 \u521b\u5efa\u4e00\u4e2a\u6a21\u578b\u6765\u5b9e\u73b0\u4ece <strong>worldcities<\/strong> \u8868\u8bfb\u53d6\u6570\u636e\u3002<\/p>\n<ol>\n<li>\u6309 <strong>\u2325R<\/strong> \/ <strong>Ctrl+Alt+R<\/strong> \u542f\u52a8 <strong>manage.py<\/strong> \u4efb\u52a1\u63a7\u5236\u53f0\u3002\u00a0<\/li>\n<li>\u8f93\u5165 <kbd>inspectdb worldcities<\/kbd> \u5e76\u6309 <strong>Enter<\/strong>\u3002<\/li>\n<li>\u5c06 <code>Worldcities<\/code> \u7c7b\u4ece\u63a7\u5236\u53f0\u8f93\u51fa\u590d\u5236\u5230 <strong>meteomodels.py<\/strong>\u3002<\/li>\n<li>\u5c06 id \u5b57\u6bb5\u7684 <code>null=True<\/code> \u66ff\u6362\u4e3a <code>primary_key=True<\/code>\u3002<\/li>\n<\/ol>\n<p>\u4ee5\u4e0b\u662f\u5b83\u7684\u6837\u5b50\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"9\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">from django.db import models\n\n\nclass Worldcities(models.Model):\n    city = models.TextField(blank=True, null=True)\n    lat = models.FloatField(blank=True, null=True)\n    lng = models.FloatField(blank=True, null=True)\n    country = models.TextField(blank=True, null=True)\n    id = models.IntegerField(blank=True, primary_key=True)\n\n    class Meta:\n        managed = False\n        db_table = 'worldcities'<\/pre>\n<h3 class=\"wp-block-heading\">\u6dfb\u52a0\u529f\u80fd<\/h3>\n<p>\u76ee\u524d\u4e3a\u6b62\uff0c\u6211\u4eec\u5728 <strong>views.py<\/strong> \u4e2d\u53ea\u6709\u4e00\u4e2a\u51fd\u6570 (<code>temp_here<\/code>) \u53ef\u4ee5\u8fd4\u56de\u6709\u5173\u60a8\u6240\u5728\u4f4d\u7f6e\u5f53\u524d\u6e29\u5ea6\u7684\u4fe1\u606f\u3002 \u6211\u4eec\u518d\u6dfb\u52a0\u4e00\u4e2a\u51fd\u6570\u6765\u663e\u793a\u968f\u673a\u4f4d\u7f6e\u7684\u6e29\u5ea6\u3002 \u5b83\u4e5f\u9700\u8981\u4ece API \u83b7\u53d6\u5f53\u524d\u6e29\u5ea6\u6570\u636e\uff0c\u56e0\u6b64\u6839\u636e Python \u6700\u4f73\u505a\u6cd5\uff0c\u6211\u4eec\u5e94\u8be5\u5c06\u8be5\u529f\u80fd\u79fb\u52a8\u5230\u5355\u72ec\u7684\u51fd\u6570\u3002<\/p>\n<p>\u5728 PyCharm \u4e2d\uff0c\u8fd9\u53ef\u4ee5\u901a\u8fc7 <strong>Extract method<\/strong>\uff08\u63d0\u53d6\u65b9\u6cd5\uff09\u91cd\u6784\u8f7b\u677e\u5b8c\u6210\u3002<\/p>\n<p>\u9009\u62e9\u5e94\u79fb\u81f3\u5355\u72ec\u51fd\u6570\u7684\u884c\uff0c\u7136\u540e\u6309 <strong>\u2325\u2318M<\/strong> \/ <strong>Ctrl+Alt+M<\/strong>\u3002 \u6216\u8005\uff0c\u4f7f\u7528 <strong>Find Action<\/strong>\uff08\u67e5\u627e\u64cd\u4f5c\uff09\uff1a<\/p>\n<figure class=\"wp-block-video aligncenter\"><video src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/extract_method.mp4\" controls=\"controls\" width=\"300\" height=\"150\"><\/video><\/figure>\n<p>\u5728 <strong>Method name<\/strong>\uff08\u65b9\u6cd5\u540d\u79f0\uff09\u5b57\u6bb5\u4e2d\u6307\u5b9a <code>get_temp<\/code>\uff0c\u7136\u540e\u70b9\u51fb <strong>OK<\/strong>\uff08\u786e\u5b9a\uff09\u3002 \u6211\u4eec\u73b0\u5728\u6709\u4e86\u63a5\u53d7 <code>location<\/code> \u4f5c\u4e3a\u552f\u4e00\u5f62\u53c2\u7684 <code>get_temp<\/code> \u51fd\u6570\u3002<\/p>\n<p><code>temp_here<\/code> \u51fd\u6570\u8c03\u7528\u5b83\u6765\u63a5\u6536\u5f53\u524d\u4f4d\u7f6e\u7684\u6e29\u5ea6\u3002<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335315\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/after_extract_method.png\" alt=\"Extract Method\uff08\u63d0\u53d6\u65b9\u6cd5\uff09\u91cd\u6784\u7684\u7ed3\u679c\" width=\"892\" height=\"528\" \/><\/figure>\n<\/div>\n<p>\u6211\u4eec\u6765\u521b\u5efa <code>temp_somewhere<\/code> \u51fd\u6570\u3002 \u5b83\u5e94\u8be5\u5c06\u968f\u673a\u57ce\u5e02\u7684\u5750\u6807\u4f20\u9012\u7ed9 <code>get_temp<\/code>\u3002<\/p>\n<p>\u9996\u5148\uff0c\u5728 Python \u63a7\u5236\u53f0\u4e2d\u8fdb\u884c\u4e00\u4e9b\u539f\u578b\u8bbe\u8ba1\u3002 \u6253\u5f00\u5e76\u7c98\u8d34\u4ee5\u4e0b\u4ee3\u7801\uff08\u5982\u679c\u51fa\u73b0 <code>ImportError<\/code>\uff0c\u5219\u5173\u95ed\u5e76\u91cd\u65b0\u6253\u5f00\u63a7\u5236\u53f0\uff09\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">from meteo.models import Worldcities\nrandom_item = Worldcities.objects.all().order_by('?').first()<\/pre>\n<p>\u6211\u4eec\u9700\u8981\u4ece <strong>worldcities<\/strong> \u8868\u83b7\u53d6\u6570\u636e\u3002 \u8fd9\u662f\u901a\u8fc7\u6a21\u578b\u5b8c\u6210\u7684\uff0c\u56e0\u6b64\u6211\u4eec\u4ece <strong>models.py<\/strong> \u5bfc\u5165 <code>Worldcities<\/code> \u6a21\u578b\u3002<\/p>\n<p>\u7136\u540e\uff0c\u4f7f\u7528 <code>order_by(\u2018?\u2019)<\/code> \u968f\u673a\u5316\u6240\u6709\u5bf9\u8c61\u5e76\u4f7f\u7528 <code>first()<\/code> \u83b7\u5f97\u7b2c\u4e00\u4e2a\u5bf9\u8c61\u3002 \u5728 <strong>Python console<\/strong>\uff08Python \u63a7\u5236\u53f0\uff09\u5de5\u5177\u7a97\u53e3\u7684\u53f3\u4fa7\uff0c\u6709\u4e00\u4e2a <strong>Variables<\/strong>\uff08\u53d8\u91cf\uff09\u6807\u7b7e\u9875\u3002 \u5c55\u5f00 <strong>random_item<\/strong> \u8282\u70b9\uff0c\u67e5\u770b <code>random_item<\/code> \u7684\u5185\u5bb9\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335326\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/manual_request_2.png\" alt=\"\u5728 Python \u63a7\u5236\u53f0\u7684 Variables\uff08\u53d8\u91cf\uff09\u6807\u7b7e\u9875\u4e2d\u68c0\u67e5\u53d8\u91cf\" width=\"800\" height=\"266\" \/><\/figure>\n<\/div>\n<p><code>temp_somewhere<\/code> \u51fd\u6570\u7684\u5b8c\u6574\u4ee3\u7801\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">def temp_somewhere(request):\n    random_item = Worldcities.objects.all().order_by('?').first()\n    city = random_item.city\n    location = [random_item.lat, random_item.lng]\n    temp = get_temp(location)\n    template = loader.get_template(\"index.html\")\n    context = {\n        'city': city,\n        'temp': temp\n    }\n    return HttpResponse(template.render(context, request))<\/pre>\n<p>\u9664\u4e86\u6e29\u5ea6\uff0c<code>context<\/code> \u73b0\u5728\u8fd8\u5305\u542b\u57ce\u5e02\u540d\u79f0\u3002 \u6211\u4eec\u6765\u7f16\u8f91\u6a21\u677f\uff0c\u4f7f\u5176\u4e5f\u5448\u73b0\u6b64\u4fe1\u606f\u3002<\/p>\n<p>\u60a8\u53ef\u80fd\u5df2\u7ecf\u6ce8\u610f\u5230\u88c5\u8ba2\u533a\u57df\u4e2d\u7684 <strong>&lt;&gt;<\/strong> \u56fe\u6807\u3002 \u70b9\u51fb\u4ee5\u5feb\u901f\u5207\u6362\u5230 <strong>index.html<\/strong>\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335337\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/gutter_icon.png\" alt=\"\u7528\u4e8e\u5feb\u901f\u8bbf\u95ee\u6a21\u677f\u6587\u4ef6\u7684\u88c5\u8ba2\u533a\u57df\u56fe\u6807\" width=\"613\" height=\"277\" \/><\/figure>\n<\/div>\n<p>\u5c06 <code>&lt;h1&gt;&lt;\/h1&gt;<\/code> \u6807\u8bb0\u4e4b\u95f4\u7684\u6587\u672c\u66ff\u6362\u4e3a <code>{{ city }}<\/code>\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335348\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/replace_h1.png\" alt=\"\u5c06\u6807\u9898\u66ff\u6362\u4e3a\u53d8\u91cf\" width=\"674\" height=\"400\" \/><\/figure>\n<\/div>\n<p>\u70b9\u51fb\u88c5\u8ba2\u533a\u57df\u56fe\u6807\u53ef\u5feb\u901f\u8bbf\u95ee <code>temp_here<\/code> \u51fd\u6570\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335359\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/gutter_icon_2.png\" alt=\"\u7528\u4e8e\u5feb\u901f\u8bbf\u95ee Python \u6587\u4ef6\u7684\u88c5\u8ba2\u533a\u57df\u56fe\u6807\" width=\"670\" height=\"332\" \/><\/figure>\n<\/div>\n<p>\u6211\u4eec\u9700\u8981\u4fee\u6539\u5b83\uff0c\u4f7f\u5b83\u4e5f\u4f20\u9012 <code>city<\/code> \u53d8\u91cf\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335370\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/modified_temp_here.png\" alt=\"\u66f4\u65b0 temp_here \u51fd\u6570\" width=\"604\" height=\"225\" \/><\/figure>\n<\/div>\n<p>\u5728\u6d4f\u89c8\u5668\u4e2d\u6253\u5f00 <kbd>https:\/\/127.0.0.1\/meteo<\/kbd> \u9875\u9762\u65f6\u5c06\u8c03\u7528 <code>temp_here<\/code> \u51fd\u6570\uff0c\u6211\u4eec\u5df2\u5728 <strong>meteo\/urls.py<\/strong> \u4e2d\u5b8c\u6210\u914d\u7f6e\u3002<\/p>\n<p>\u6211\u4eec\u56de\u5230\u90a3\u91cc\uff0c\u6307\u5b9a\u5728\u8bbf\u95ee <kbd>https:\/\/127.0.0.1\/meteo\/discover<\/kbd> \u65f6\u5e94\u8c03\u7528 <code>temp_somewhere<\/code>\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"3\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">urlpatterns = [\n    path('meteo\/', views.temp_here, name='temp_here'),\n    path('meteo\/discover', views.temp_somewhere, name='temp_somewhere'),\n]<\/pre>\n<p>\u8fd4\u56de <strong>index.html<\/strong>\uff0c\u6dfb\u52a0\u6307\u5411 <strong>\/discover<\/strong> \u9875\u9762\u548c\u9996\u9875\u7684\u94fe\u63a5\u3002 \u540e\u8005\u5c06\u59cb\u7ec8\u663e\u793a\u5f53\u524d\u4f4d\u7f6e\u7684\u6e29\u5ea6\u3002 \u5b9e\u65f6\u6a21\u677f\u548c\u4ee3\u7801\u8865\u5168\u53ef\u4ee5\u8282\u7701\u5927\u91cf\u65f6\u95f4\uff1a<\/p>\n<figure class=\"wp-block-video aligncenter\"><video src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/completion_add_links_to_template.mp4\" controls=\"controls\" width=\"300\" height=\"150\"><\/video><\/figure>\n<p>\u8981\u5bf9 html \u6587\u4ef6\u4e2d\u7684\u6bb5\u843d\u548c\u94fe\u63a5\u4f7f\u7528\u5b9e\u65f6\u6a21\u677f\uff0c\u53ea\u9700\u5206\u522b\u8f93\u5165 <kbd>p<\/kbd> \u6216 <kbd>a<\/kbd> \uff0c\u7136\u540e\u6309 <strong>Tab<\/strong>\u3002<\/p>\n<p>\u8981\u67e5\u770b\u53ef\u7528\u5b9e\u65f6\u6a21\u677f\u7684\u5b8c\u6574\u5217\u8868\uff0c\u9996\u5148\u6253\u5f00\u8bbe\u7f6e (<strong>\u2318<\/strong> \/ <strong>Ctrl+Alt+S<\/strong>)\uff0c\u8f6c\u5230 <strong>Editor &gt; Live Templates<\/strong>\uff08\u7f16\u8f91\u5668 &gt; \u5b9e\u65f6\u6a21\u677f\uff09\uff0c\u7136\u540e\u5c55\u5f00\u53f3\u7a97\u683c\u4e2d\u7684 <strong>Zen HTML<\/strong> \u8282\u70b9\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335392\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/live_templates_settings.png\" alt=\"\u914d\u7f6e\u5b9e\u65f6\u6a21\u677f\u8bbe\u7f6e\" width=\"800\" height=\"584\" \/><\/figure>\n<\/div>\n<p>\u60a8\u53ef\u4ee5\u91cd\u65b0\u8fd0\u884c\u670d\u52a1\u5668\u5e76\u8bd5\u7528\u5e94\u7528\u7a0b\u5e8f\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335403\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/play_with_links.gif\" alt=\"\" width=\"351\" height=\"205\" \/><\/figure>\n<\/div>\n<h2 class=\"wp-block-heading\">\u8fd8\u6ca1\u7ed3\u675f<\/h2>\n<p>\u5e94\u7528\u73b0\u5728\u53ef\u4ee5\u8fd0\u884c\uff0c\u4f46\u8fd8\u6709\u6539\u8fdb\u7684\u7a7a\u95f4\u3002 \u6700\u660e\u663e\u7684\u662f\u89c6\u89c9\u5916\u89c2\uff0c\u4f46\u4e5f\u8fd8\u53ef\u4ee5\u6dfb\u52a0\u989d\u5916\u529f\u80fd\u3002<\/p>\n<h3 class=\"wp-block-heading\">\u4f7f\u7528 CSS<\/h3>\n<p>CSS \u662f\u4f7f Django \u5e94\u7528\u7a0b\u5e8f\u770b\u8d77\u6765\u66f4\u597d\u7684\u6700\u5feb\u4e5f\u6700\u7b80\u5355\u7684\u65b9\u5f0f\u3002 \u4f8b\u5982\uff0c\u4f7f\u7528 <a href=\"https:\/\/simplecss.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Simple.CSS<\/a>\u3002<\/p>\n<p>\u5c06\u4ee5\u4e0b\u884c\u653e\u5728 <strong>index.html<\/strong> \u4e2d <code>&lt;head&gt;&lt;\/head&gt;<\/code> \u6807\u8bb0\u4e4b\u95f4\u7684\u4efb\u610f\u4f4d\u7f6e\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;link rel=\"stylesheet\" href=\"https:\/\/cdn.simplecss.org\/simple.min.css\"&gt;<\/pre>\n<p>\u65b0\u5916\u89c2\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335414\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/image-52.png\" alt=\"\u5e94\u7528 CSS\" width=\"296\" height=\"333\" \/><\/figure>\n<\/div>\n<p>\u5c06\u94fe\u63a5\u66ff\u6362\u4e3a\u6309\u94ae\u4e5f\u5c06\u6539\u5584\u5916\u89c2\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335425\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/image-53.png\" alt=\"\u5c06\u94fe\u63a5\u66ff\u6362\u4e3a\u6309\u94ae\" width=\"319\" height=\"347\" \/><\/figure>\n<\/div>\n<p>\u4e3a\u6b64\uff0c\u5c06 <strong>index.html<\/strong> \u4e2d <code>&lt;p&gt;&lt;\/p&gt;<\/code> \u6807\u8bb0\u4e4b\u95f4\u7684\u94fe\u63a5\u66ff\u6362\u4e3a\u4ee5\u4e0b html \u4ee3\u7801\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;div style=\"display: flex;\"&gt;\n    &lt;form action=\".\/discover\"&gt;\n        &lt;input type=\"submit\" value=\"Check other places\"\/&gt;\n    &lt;\/form&gt;\n    &amp;nbsp;\n    &lt;form action=\".\"&gt;\n        &lt;input style=\"background: #dc3545\" type=\"submit\" value=\"Home\"\/&gt;\n    &lt;\/form&gt;\n&lt;\/div&gt;<\/pre>\n<p>\u65e0\u9700\u4ece PyCharm \u5207\u6362\u5230\u6d4f\u89c8\u5668\u5373\u53ef\u770b\u5230\u7f16\u8f91 <strong>index.html<\/strong> \u7684\u7ed3\u679c\u3002 \u5c06\u9f20\u6807\u60ac\u505c\u5728\u7f16\u8f91\u5668\u7a97\u53e3\u7684\u53f3\u4e0a\u89d2\uff0c\u9009\u62e9 <strong>Built-in Preview<\/strong>\uff08\u5185\u7f6e\u9884\u89c8\uff09\uff1a<\/p>\n<figure class=\"wp-block-video\"><video src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/built_in_preview.mp4\" controls=\"controls\" width=\"300\" height=\"150\"><\/video><\/figure>\n<h3 class=\"wp-block-heading\">\u4f7f\u7528 Bootstrap<\/h3>\n<p><a href=\"https:\/\/getbootstrap.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Bootstrap<\/a> \u662f\u4e00\u4e2a\u5f3a\u5927\u4e14\u514d\u8d39\u7684\u524d\u7aef\u5de5\u5177\u5305\u3002 \u8981\u5c06\u5b83\u5feb\u901f\u5e94\u7528\u5230 Django \u5e94\u7528\uff0c\u6309\u5982\u4e0b\u6240\u793a\u7f16\u8f91 <strong>index.html<\/strong>\uff08\u6709\u5173\u8be6\u60c5\uff0c\u8bf7\u53c2\u9605 <a href=\"https:\/\/getbootstrap.com\/docs\/5.3\/getting-started\/introduction\/#quick-start\" target=\"_blank\" rel=\"noreferrer noopener\">Bootstrap \u5feb\u901f\u5165\u95e8\u6307\u5357<\/a>\uff09\uff1a<\/p>\n<ol>\n<li>\u5c06 <code>link<\/code> \u6807\u8bb0\u6dfb\u52a0\u5230 html \u5934\u90e8\uff08\u66ff\u6362\u524d\u9762\u6b65\u9aa4\u4e2d\u7684 simple.css\uff09\uff1a<\/li>\n<\/ol>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;link href=\"https:\/\/cdn.jsdelivr.net\/npm\/bootstrap@5.3.0-alpha1\/dist\/css\/bootstrap.min.css\" rel=\"stylesheet\" integrity=\"sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3\/Jr59b6EGGoI1aFkw7cmDA6j6gD\" crossorigin=\"anonymous\"&gt;<\/pre>\n<p>2. \u5728 <code>&lt;body&gt;&lt;\/body&gt;<\/code> \u6807\u8bb0\u5185\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;div class=\"container text-center\"&gt;\n    &lt;h1&gt;{{ city }}&lt;\/h1&gt;\n    &lt;h2&gt;{{ temp }} \u2103&lt;\/h2&gt;\n    &lt;div class=\"btn-group\" role=\"group\"&gt;\n        &lt;button type=\"button\" class=\"btn btn-outline-primary\" onclick=\"location.href='.\/discover'\"&gt;Check other places\n        &lt;\/button&gt;\n        &lt;button type=\"button\" class=\"btn btn-danger\" onclick=\"location.href='.'\"&gt;Home&lt;\/button&gt;\n    &lt;\/div&gt;\n&lt;\/div&gt;\n&lt;script src=\"https:\/\/cdn.jsdelivr.net\/npm\/bootstrap@5.3.0-alpha1\/dist\/js\/bootstrap.bundle.min.js\" integrity=\"sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN\" crossorigin=\"anonymous\"&gt;&lt;\/script&gt;<\/pre>\n<p>\u67e5\u770b\u7ed3\u679c\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335471\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/bootstrap.gif\" alt=\"\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u4f7f\u7528 Bootstrap\" width=\"300\" height=\"178\" \/><\/figure>\n<\/div>\n<p>Bootstrap \u63d0\u4f9b\u4e86\u591a\u79cd\u81ea\u5b9a\u4e49\u5e94\u7528\u5916\u89c2\u7684\u65b9\u5f0f\u3002 \u60a8\u53ef\u4ee5\u5728<a href=\"https:\/\/getbootstrap.com\/docs\/5.3\/getting-started\/introduction\/\" target=\"_blank\" rel=\"noreferrer noopener\">\u6587\u6863<\/a>\u4e2d\u627e\u5230\u6240\u6709\u5fc5\u8981\u4fe1\u606f\u3002<\/p>\n<h3 class=\"wp-block-heading\">\u4eb2\u81ea\u5c1d\u8bd5<\/h3>\n<p>\u6211\u4eec\u5df2\u5c06 <strong>worldcities<\/strong> \u6570\u636e\u5e93\u7684 <code>country<\/code> \u5b57\u6bb5\u6dfb\u52a0\u5230 <code>Worldcities<\/code> \u6a21\u578b\u4e2d\uff0c\u4f46\u5e76\u672a\u5728\u5e94\u7528\u7684\u4efb\u4f55\u5730\u65b9\u4f7f\u7528\u8be5\u6570\u636e\u3002 \u73b0\u5728\uff0c\u60a8\u8fd8\u53ef\u4ee5\u6d4b\u8bd5\u81ea\u5df1\u7684\u6280\u80fd\uff0c\u8ba9\u5e94\u7528\u9664\u4e86\u57ce\u5e02\u540d\u79f0\u4e4b\u5916\u8fd8\u663e\u793a\u56fd\u5bb6\/\u5730\u533a\u3002 \u7ed3\u679c\u5e94\u8be5\u7c7b\u4f3c\u4e8e\uff1a<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-335482\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/03\/check_yourself.gif\" alt=\"\u5c06\u56fd\u5bb6\/\u5730\u533a\u4fe1\u606f\u6dfb\u52a0\u5230\u5e94\u7528\u7a0b\u5e8f\" width=\"262\" height=\"286\" \/><\/figure>\n<\/div>\n<h2 class=\"wp-block-heading\">\u603b\u7ed3<\/h2>\n<p>\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5b66\u4e60\u4e86\u5982\u4f55\uff1a<\/p>\n<ul>\n<li>\u5728 PyCharm \u4e2d\u521b\u5efa Django \u9879\u76ee\u3002<\/li>\n<li>\u7f16\u5199\u89c6\u56fe\u548c\u521b\u5efa\u6a21\u677f\u3002<\/li>\n<li>\u8fdb\u884c API \u8c03\u7528\u5e76\u5904\u7406\u54cd\u5e94\u3002<\/li>\n<li>\u8fde\u63a5\u6570\u636e\u5e93\u548c\u5bfc\u5165\u6570\u636e\u3002<\/li>\n<li>\u5e94\u7528 CSS \u548c Bootstrap \u6539\u5584\u5e94\u7528\u7684\u89c6\u89c9\u5916\u89c2\u3002<\/li>\n<\/ul>\n\n\n<p><\/p>\n\n\n\n<p>\u672c\u535a\u6587\u82f1\u6587\u539f\u4f5c\u8005\uff1a<\/p>\n\n\n    <div class=\"about-author \">\n        <div class=\"about-author__box\">\n            <div class=\"row\">\n                <div class=\"about-author__box-img\">\n                    <img decoding=\"async\" src=\"https:\/\/secure.gravatar.com\/avatar\/?s=200&#038;r=g\" width=\"200\" height=\"200\" alt=\"\" loading=\"lazy\"  class=\"avatar avatar-200 wp-user-avatar wp-user-avatar-200 photo avatar-default\">\n                <\/div>\n                <div class=\"about-author__box-text\">\n                                                        <\/div>\n            <\/div>\n        <\/div>\n    <\/div>\n","protected":false},"author":1297,"featured_media":337870,"comment_status":"closed","ping_status":"closed","template":"","categories":[2347],"tags":[],"cross-post-tag":[],"acf":[],"_links":{"self":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/pycharm\/352828"}],"collection":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/pycharm"}],"about":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/types\/pycharm"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/users\/1297"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/comments?post=352828"}],"version-history":[{"count":5,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/pycharm\/352828\/revisions"}],"predecessor-version":[{"id":356136,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/pycharm\/352828\/revisions\/356136"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/media\/337870"}],"wp:attachment":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/media?parent=352828"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/categories?post=352828"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/tags?post=352828"},{"taxonomy":"cross-post-tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/cross-post-tag?post=352828"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}