{"id":971,"date":"2019-05-04T04:21:39","date_gmt":"2019-05-03T19:21:39","guid":{"rendered":"https:\/\/www.nblog09.com\/w\/?p=971"},"modified":"2021-06-25T13:17:35","modified_gmt":"2021-06-25T04:17:35","slug":"python-anywhere-release","status":"publish","type":"post","link":"https:\/\/www.nblog09.com\/w\/2019\/05\/04\/python-anywhere-release\/","title":{"rendered":"Python Anywhere\u3067Django\u30a2\u30d7\u30ea\u3092\u30ea\u30ea\u30fc\u30b9\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u307e\u3068\u3081\u307e\u3057\u305f"},"content":{"rendered":"<p>PythonAnywhere\u306b\u3064\u3044\u3066\u306e\u8a73\u7d30\u306f<a href=\"https:\/\/www.nblog09.com\/w\/2019\/05\/04\/python-anywhere\/\">\u3053\u3061\u3089<\/a>\u306b\u307e\u3068\u3081\u305f\u304c\u3001\u4eca\u56de\u306f\u3001Python Anywhere\u4e0a\u3067Django\u306e\u30a2\u30d7\u30ea\u3092\u30ea\u30ea\u30fc\u30b9\u3059\u308b\u624b\u9806\u306b\u3064\u3044\u3066\u7d39\u4ecb\u3059\u308b\u3002<\/p>\n<h2 class=\"title-border\"><strong>Python Anywhere\u306e\u30b3\u30f3\u30bd\u30fc\u30eb\u304b\u3089\u4eee\u60f3\u74b0\u5883\u306e\u4f5c\u6210\u3001\u30a2\u30d7\u30ea\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/strong><\/h2>\n<div class=\"simple-box3\">\n<h3 class=\"under-blue\"><strong>1. Python Anywhere\u306e\u30b5\u30a4\u30c8\u304b\u3089\u4eee\u60f3\u74b0\u5883\u306e\u4f5c\u6210<\/strong><\/h3>\n<\/div>\n<p><span class=\"pink_span\">\u4eee\u60f3\u74b0\u5883\u306e\u4f5c\u6210\u306b\u306f\u3001\u30b3\u30f3\u30bd\u30fc\u30eb\u3092\u7acb\u3061\u4e0a\u3052\u3001\u4ee5\u4e0b\u306emkvirtualenv\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u3088\u3044\u3002<\/span><br \/>\n\uff08\u30b3\u30f3\u30bd\u30fc\u30eb\u3092\u7acb\u3061\u4e0a\u3052\u308b\u306b\u306f\u3001\u753b\u9762\u304b\u3089Console\u30bf\u30d6\u2192Bash\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\uff09<\/p>\n<div class=\"interview-aite\">\n<strong>mkvirtualenv --python=python3.7(python version) \u74b0\u5883\u540d<\/strong>\n<\/div>\n<p>\u7d42\u4e86\u3059\u308b\u3068\u3001\u81ea\u5206\u304c\u6307\u5b9a\u3057\u305f\u74b0\u5883\u540d\u306e\u4eee\u60f3\u74b0\u5883\u304c\u4f5c\u6210\u3055\u308c\u3001activate\u3055\u308c\u305f\u72b6\u614b\u306b\u306a\u308b\u3002<\/p>\n<p>\u3061\u306a\u307f\u306bdeactivate\u3059\u308b\u306b\u306f\u3001<\/p>\n<div class=\"interview-aite\">\n<strong>deactivate<\/strong>\n<\/div>\n<p>\u3092\u5b9f\u884c\u3059\u308b\u3002<\/p>\n<p>activate\u3057\u3066\u3044\u306a\u3044\u72b6\u614b\u304b\u3089activate\u72b6\u614b\u306b\u3059\u308b\u306b\u306f\u3001<\/p>\n<div class=\"interview-aite\">\n<strong>source \u4eee\u60f3\u74b0\u5883\u306e\u30d1\u30b9(\/bin\/activate, ~\/.virtualenvs\/env\u540d\/bin\/activate)<\/strong>\n<\/div>\n<p>\u3092\u5b9f\u884c\u3059\u308b\u3002<\/p>\n<p>&nbsp;<\/p>\n<h3 class=\"under-blue\"><strong><br \/>\n2. \u81ea\u5206\u306e\u4f5c\u6210\u3057\u305fDjango\u306e\u30a2\u30d7\u30ea\u3092\u81ea\u5206\u306e\u30af\u30e9\u30a6\u30c9\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308b<br \/>\n<\/strong><\/h3>\n<p>\u65b9\u6cd5\u306f\u3001<span class=\"pink_span\">git\u7d4c\u7531\u3068\u30d5\u30a1\u30a4\u30eb\u3092\u30a2\u30d7\u30ed\u30fc\u30c9\u3059\u308b\u65b9\u6cd5<\/span>\u306e2\u901a\u308a\u3042\u308b\u3002<\/p>\n<ul>\n<li>git\u306b\u30a2\u30d7\u30ea\u3092\u4e0a\u3052\u3066\u3044\u308b\u5834\u5408\u306f\u3001git clone\u3092\u7528\u3044\u308b<\/li>\n<li>\u30d6\u30e9\u30a6\u30b6\u306e\u753b\u9762\u304b\u3089\u3001Files\u2192UploadFiles\u3067\u30ed\u30fc\u30ab\u30eb\u304b\u3089\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308b<\/li>\n<\/ul>\n<h3 class=\"under-blue\"><strong><br \/>\n3. Django\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<br \/>\n<\/strong><\/h3>\n<p>Django\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3002<\/p>\n<div class=\"interview-aite\">\npip install django==2.2.1 # django\u306eversion\n<\/div>\n<p>\u6b21\u306b\u3001Django\u4ee5\u5916\u306b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u5b9f\u884c\u306b\u5fc5\u8981\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u3082\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3002<\/p>\n<h3 class=\"under-blue\"><strong><br \/>\n4. DB\u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30c8\u3059\u308b<br \/>\n<\/strong><\/h3>\n<p>Django\u3068\u305d\u306e\u4ed6\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304c\u5b8c\u4e86\u3057\u305f\u3089\u3001\u30de\u30a4\u30b0\u30ec\u30fc\u30c8\u3092\u3057\u3066\u3001DB\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u5b9f\u884c<\/p>\n<div class=\"interview-aite\">\npython manage.py migrate<br \/>\npython manage.py makemigrations \u30a2\u30d7\u30ea\u540d<br \/>\npython manage.py migrate\n<\/div>\n<h2 class=\"title-border\"><strong><br \/>\nPython Anywhere\u306e\u30a2\u30d7\u30ea\u8a2d\u5b9a<br \/>\n<\/strong><\/h2>\n<p>Python Anywhere\u306e<a href=\"https:\/\/www.nblog09.com\/w\/2019\/05\/04\/python-anywhere\/\">\u753b\u9762<\/a>\u304b\u3089\u3001\u30a2\u30d7\u30ea\u306e\u8a2d\u5b9a\u3092\u884c\u3046\u3002<\/p>\n<p>\u307e\u305a\u3001\u753b\u9762\u2192Web\u2192Add a new web app\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3002<\/p>\n<p>\u4eca\u56de\u306f\u3001\u81ea\u5206\u304c\u4f5c\u6210\u3057\u305f\u30a2\u30d7\u30ea\u3092\u30ea\u30ea\u30fc\u30b9\u3059\u308b\u306e\u3067Django\u3067\u306a\u304f\u3001Manual Configuration\u3092\u9078\u629e\u3059\u308b\u3002<\/p>\n<p>\u753b\u9762\u2192Web\u304b\u3089\u4ee5\u4e0b\u306e\uff12\u70b9\u3092\u5909\u66f4<\/p>\n<ul>\n<li><strong>Working directory<\/strong><\/li>\n<\/ul>\n<p>Web\u753b\u9762\u306eCode:\u306b\u3042\u308b\u3001Working directory:\u3092<span class=\"pink_span\">\u81ea\u5206\u304cupload\u3057\u305f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30d1\u30b9\u306b\u8a2d\u5b9a\u3059\u308b\u3002<\/span><\/p>\n<ul>\n<li><strong>Virtualenv<\/strong><\/li>\n<\/ul>\n<p>Virtualenv\u306b\u306f\u3001<span class=\"pink_span\">\u81ea\u5206\u304c\u4f5c\u6210\u3057\u305f\u4eee\u60f3\u74b0\u5883\u306e\u30d1\u30b9\u306b\u8a2d\u5b9a\u3059\u308b\u3002(~\/.virtualenvs\/myenv)<\/span><\/p>\n<ul>\n<li><strong>wsgi\u30d5\u30a1\u30a4\u30eb<\/strong><\/li>\n<\/ul>\n<p>Code: \u306eWSGI configuration file:\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3002<\/p>\n<p>74\u884c\u76ee\u4ee5\u964d\u3001DJANGO\u306e\u8a2d\u5b9a\u306b\u3064\u3044\u3066\u8a18\u8f09\u3055\u308c\u3066\u3044\u308b\u90e8\u5206\u306b<span class=\"pink_span\">\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u633f\u5165\u3059\u308b\u3002<\/span><\/p>\n<div class=\"interview-aite\">\nimport os<br \/>\nimport sys<br \/>\n#<br \/>\n## assuming your django settings file is at '\/home\/User\/mysite\/mysite\/settings.py'<br \/>\n## and your manage.py is is at '\/home\/User\/mysite\/manage.py'<br \/>\npath = '\/home\/User\u540d\/\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30d1\u30b9'<br \/>\nif path not in sys.path:<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;sys.path.append(path)<\/p>\n<p>os.chdir(path)<br \/>\nos.environ.setdefault(\"DJANGO_SETTINGS_MODULE\", \"\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u540d.settings\")<\/p>\n<p>import django<br \/>\ndjango.setup()<br \/>\n#<br \/>\n## then:<br \/>\nfrom django.core.wsgi import get_wsgi_application<br \/>\napplication = get_wsgi_application()\n<\/p><\/div>\n<p>\u7de8\u96c6\u5f8c\u306b\u306f\u3001\u753b\u9762\u4e0a\u306eWeb\u753b\u9762\u304b\u3089<span class=\"pink_span\">Reload\u3092\u5b9f\u884c\uff08\u753b\u9762\u4e0a\u90e8\u306e\u7dd1\u8272\u306e\u30dc\u30bf\u30f3\uff09\u3059\u308b\u3002<\/span><\/p>\n<ul>\n<li><strong>ALLOWED_HOSTS\u306b\u81ea\u5206\u306e\u30db\u30b9\u30c8\u540d\u3092\u8ffd\u52a0<\/strong><\/li>\n<\/ul>\n<p>\u6700\u5f8c\u306b\u3001Django\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306esettings.py\u30d5\u30a1\u30a4\u30eb\u306b\u4ee5\u4e0b\u306e\u8a18\u8ff0\u3092\u8ffd\u52a0\u3059\u308b\u3002<\/p>\n<div class=\"interview-aite\">\nALLOWED_HOSTS = ['\u30db\u30b9\u30c8\u540d(\u81ea\u5206\u306e\u30a2\u30ab\u30a6\u30f3\u30c8\u540d.pythonanywhere.com)',]\n<\/div>\n<p>\u6700\u5f8c\u306b\u3001\u753b\u9762\u4e0a\u306eWeb\u753b\u9762\u304b\u3089Reload\u3092\u5b9f\u884c\uff08\u753b\u9762\u4e0a\u90e8\u306e\u7dd1\u8272\u306e\u30dc\u30bf\u30f3\uff09\u3057\u3066\u3001<\/p>\n<p><strong>http:\/\/\u81ea\u5206\u306e\u30a2\u30ab\u30a6\u30f3\u30c8\u540d.pythonanywhere.com\/<\/strong><\/p>\n<p>\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u81ea\u5206\u304c\u4f5c\u6210\u3057\u305f\u30a2\u30d7\u30ea\u3092\u898b\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\n<div class=\"customized-adsense\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>PythonAnywhere\u306b\u3064\u3044\u3066\u306e\u8a73\u7d30\u306f\u3053\u3061\u3089\u306b\u307e\u3068\u3081\u305f\u304c\u3001\u4eca\u56de\u306f\u3001Python Anywhere\u4e0a\u3067Django\u306e\u30a2\u30d7\u30ea\u3092\u30ea\u30ea\u30fc\u30b9\u3059\u308b\u624b\u9806\u306b\u3064\u3044\u3066\u7d39\u4ecb\u3059\u308b\u3002 Python Anywhere\u306e\u30b3\u30f3\u30bd\u30fc\u30eb\u304b\u3089\u4eee\u60f3\u74b0\u5883\u306e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_uag_custom_page_level_css":"","_uf_show_specific_survey":0,"_uf_disable_surveys":false,"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[9,219],"tags":[225],"class_list":{"0":"post-971","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-python","7":"category-it-programming","8":"tag-pythonanywhere","9":"entry"},"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"home-middle":false,"home-top":false,"sidebar-thumbnail":false},"uagb_author_info":{"display_name":"9nmatsumoto","author_link":"https:\/\/www.nblog09.com\/w\/author\/9nmatsumoto\/"},"uagb_comment_info":1,"uagb_excerpt":"PythonAnywhere\u306b\u3064\u3044\u3066\u306e\u8a73\u7d30\u306f\u3053\u3061\u3089\u306b\u307e\u3068\u3081\u305f\u304c\u3001\u4eca\u56de\u306f\u3001Python Anywhere\u4e0a\u3067Dj&hellip;","_links":{"self":[{"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/posts\/971","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/comments?post=971"}],"version-history":[{"count":14,"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/posts\/971\/revisions"}],"predecessor-version":[{"id":3440,"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/posts\/971\/revisions\/3440"}],"wp:attachment":[{"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/media?parent=971"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/categories?post=971"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/tags?post=971"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}