{"id":21234,"date":"2024-03-05T17:49:41","date_gmt":"2024-03-05T09:49:41","guid":{"rendered":"https:\/\/h5app.yimenapp.cn\/h5app\/?p=21234"},"modified":"2024-03-05T17:49:41","modified_gmt":"2024-03-05T09:49:41","slug":"django%e6%89%93%e5%8c%85apk%e6%8a%80%e6%9c%af%e5%8e%9f%e7%90%86%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/h5app.yimenapp.cn\/h5app\/2024\/sjapp\/21234\/","title":{"rendered":"django\u6253\u5305apk\u6280\u672f\u539f\u7406\u4ecb\u7ecd"},"content":{"rendered":"<p>Django\u662f\u4e00\u4e2a\u4f7f\u7528Python\u8bed\u8a00\u5f00\u53d1\u7684Web\u5e94\u7528\u7a0b\u5e8f\u6846\u67b6\uff0c\u5b83\u91c7\u7528\u4e86MVC\uff08Model-View-Controller\uff09\u7684\u8bbe\u8ba1\u6a21\u5f0f\uff0c\u5177\u6709\u9ad8\u5ea6\u7684\u7075\u6d3b\u6027\u548c\u53ef\u6269\u5c55\u6027\uff0c\u53ef\u4ee5\u5feb\u901f\u5730\u5f00\u53d1\u51fa\u9ad8\u8d28\u91cf\u7684Web\u5e94\u7528\u7a0b\u5e8f\u3002\u5728Web\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6709\u65f6\u9700\u8981\u5c06Django\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210Android APK\u6587\u4ef6\uff0c\u4ee5\u4fbf\u5728Android\u8bbe\u5907\u4e0a\u8fd0\u884c\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Python-f<a href=\"https:\/\/appdabao.yimenapp.com\/jiage-2098.html\">php\u6587\u4ef6\u6253\u5305<\/a>or-Android\u5de5\u5177\u5c06Django\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210Android APK\u6587\u4ef6\u3002<\/p>\n<p>Python-for-Android\u662f\u4e00\u4e2a\u5f00\u6e90\u7684Python\u5de5\u5177\u5305\uff0c\u5b83\u53ef\u4ee5\u5c06Python\u7a0b\u5e8f\u6253\u5305\u6210Andr<a href=\"https:\/\/appdabao.yimenapp.com\/jiage-1741.html\">ios\u73b0\u6709\u9879\u76ee\u6253\u5305\u6210sdk<\/a>oid APK\u6587\u4ef6\uff0c\u5e76\u5728Android\u8bbe\u5907\u4e0a\u8fd0\u884c\u3002Python-for-Android\u4f7f\u7528\u4e86\u4e00\u79cd\u540d\u4e3a\u201cpython-for-android\u201d\u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u8be5\u5de5\u5177\u53ef\u4ee5\u81ea\u52a8\u4e0b\u8f7d\u548c\u7f16\u8bd1Python\u89e3\u91ca\u5668\u548c\u76f8\u5173\u5e93\u6587\u4ef6\uff0c\u5e76\u5c06\u5b83\u4eec\u6253\u5305\u6210\u4e00\u4e2aAPK\u6587\u4ef6\u3002Python-for-Android\u652f\u6301\u8bb8\u591aPython\u5e93\uff0c\u5305\u62ecDjango\u3002<\/p>\n<p>\u6253\u5305Django\u5e94\u7528\u7a0b\u5e8f\u4e3aAndroid APK\u6587\u4ef6\u7684\u8fc7\u7a0b\u9700\u8981\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<p>1. \u5b89\u88c5Python-for-Android<\/p>\n<p>\u9996\u5148\u9700\u8981\u5728\u672c\u5730\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5Python-for-Android\u5de5\u5177\u5305\u3002\u53ef\u4ee5\u4ecePython-for-Android\u7684\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684\u5de5\u5177\u5305\uff0c\u5e76\u6309\u7167\u5b98\u65b9\u6587\u6863\u7684\u8bf4\u660e\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<p>2. \u521b\u5efaDjango\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u5728\u672c\u5730\u8ba1\u7b97\u673a\u4e0a\u521b\u5efa\u4e00\u4e2aDjango\u5e94\u7528\u7a0b\u5e8f\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528Django\u7684\u547d\u4ee4\u884c\u5de5\u5177\u5b8c\u6210\uff0c\u4f8b\u5982\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>django-admin startproject myproject<\/p>\n<p>&#8220;`<\/p>\n<p>\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cmyproject\u201d\u7684Django\u9879\u76ee\u3002<\/p>\n<p>3. \u914d\u7f6eDjango\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u5728Django\u5e94\u7528\u7a0b\u5e8f\u7684settings.py\u6587\u4ef6\u4e2d\uff0c\u9700\u8981\u5c06ALLOWED_HOSTS\u8bbe\u7f6e\u4e3a\u5141\u8bb8\u8bbf\u95ee\u8be5\u5e94\u7528\u7a0b\u5e8f\u7684Android\u8bbe\u5907\u7684IP\u5730\u5740\u6216\u57df\u540d\u3002\u4f8b\u5982\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>ALLOWED_HOSTS = [&#8216;192.168.1.100&#8217;, &#8216;mydomain.com&#8217;]<\/p>\n<p>&#8220;`<\/p>\n<p>\u8fd8\u9700\u8981\u5c06DEBUG\u8bbe\u7f6e\u4e3aFalse\uff0c\u4ee5\u4fbf\u5728\u751f\u4ea7\u73af\u5883\u4e0b\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u3002\u4f8b\u5982\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>DEBUG = False<\/p>\n<p>&#8220;`<\/p>\n<p>4. \u6d4b\u8bd5Django\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u5728\u672c\u5730\u8ba1\u7b97\u673a\u4e0a\u542f\u52a8Django\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5728\u6d4f\u89c8\u5668\u4e2d\u8bbf\u95ee\u8be5\u5e94\u7528\u7a0b\u5e8f\u3002\u4f8b\u5982\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>python manage.py runserver<\/p>\n<p>&#8220;`<\/p>\n<p>\u8fd9\u5c06\u542f\u52a8Django\u5f00\u53d1\u670d\u52a1\u5668\uff0c\u5e76\u5728\u672c\u5730\u8ba1\u7b97\u673a\u7684http:\/\/127.0.0.1:8000\/\u4e0a\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>5. \u6253\u5305Django\u5e94\u7528\u7a0b\u5e8f\u4e3aAndroid APK\u6587\u4ef6<\/p>\n<p>\u4f7f\u7528python-for-android\u5de5\u5177\u5c06Django\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210Android APK\u6587\u4ef6\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u6253\u5305\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>python-for-android apk &#8211;private myproject &#8211;package com.mydomain.myapp &#8211;name &#8220;My App&#8221;<\/p>\n<p>&#8220;`<\/p>\n<p>\u5176\u4e2d\uff0c&#8211;private\u9009<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.yimenyun.net\/2023-03\/29\/12\/20293273057.jpg\" \/><\/figure>\n<\/p>\n<p>\u9879\u6307\u5b9aDjango\u5e94\u7528\u7a0b\u5e8f\u7684\u6839\u76ee\u5f55\uff0c&#8211;package\u9009\u9879\u6307\u5b9a\u5e94\u7528\u7a0b\u5e8f\u7684\u5305\u540d\uff0c&#8211;name\u9009\u9879\u6307\u5b9a\u5e94\u7528\u7a0b\u5e8f\u7684\u540d\u79f0\u3002\u5728\u6253\u5305\u8fc7\u7a0b\u4e2d\uff0cpython-for-android\u5c06\u4e0b\u8f7d\u548c\u7f16\u8bd1Python\u89e3\u91ca\u5668\u548c\u76f8\u5173\u5e93\u6587\u4ef6\uff0c\u5e76\u5c06\u5b83\u4eec\u6253\u5305\u6210\u4e00\u4e2aAPK\u6587\u4ef6\u3002<\/p>\n<p>6. \u5b89\u88c5\u548c\u8fd0\u884cAndroid APK\u6587\u4ef6<\/p>\n<p>\u5c06\u751f\u6210\u7684APK\u6587\u4ef6\u4f20\u8f93\u5230Android\u8bbe\u5907\uff0c\u5e76\u5728\u8bbe\u5907\u4e0a\u5b89\u88c5\u548c\u8fd0\u884c\u8be5\u5e94\u7528\u7a0b\u5e8f\u3002\u5728\u5e94\u7528\u7a0b\u5e8f\u542f\u52a8\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528Android\u8bbe\u5907\u7684\u6d4f\u89c8\u5668\u8bbf\u95ee\u8be5\u5e94\u7528\u7a0b\u5e8f\uff0c\u4ee5\u786e\u4fdd\u5b83\u53ef\u4ee5\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n<p>\u603b\u7ed3\uff1a<\/p>\n<p>\u4f7f\u7528Python-for-Android\u5de5\u5177\u53ef\u4ee5\u5c06Django\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210Android APK\u6587\u4ef6\uff0c\u5e76\u5728Android\u8bbe\u5907\u4e0a\u8fd0\u884c\u3002\u6253\u5305\u8fc7\u7a0b\u9700\u8981\u914d\u7f6eDjango\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u4f7f\u7528python-for-android\u5de5\u5177\u8fdb\u884c\u6253\u5305\u3002\u5728\u6253\u5305\u8fc7\u7a0b\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u5c06\u751f\u6210\u7684APK\u6587\u4ef6\u4f20\u8f93\u5230Android\u8bbe\u5907\uff0c\u5e76\u5728\u8bbe\u5907\u4e0a\u5b89\u88c5\u548c\u8fd0\u884c\u8be5\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Django\u662f\u4e00\u4e2a\u4f7f\u7528Python\u8bed\u8a00\u5f00\u53d1\u7684Web\u5e94\u7528\u7a0b\u5e8f\u6846\u67b6\uff0c\u5b83\u91c7\u7528\u4e86MVC\uff08Model-View-Controller\uff09\u7684\u8bbe\u8ba1\u6a21\u5f0f\uff0c\u5177\u6709\u9ad8\u5ea6\u7684\u7075\u6d3b\u6027\u548c\u53ef\u6269\u5c55\u6027\uff0c\u53ef\u4ee5\u5feb\u901f\u5730\u5f00\u53d1\u51fa\u9ad8\u8d28\u91cf\u7684Web\u5e94\u7528<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[24198,3348,11,81,24199],"topic":[],"class_list":["post-21234","post","type-post","status-publish","format-standard","hentry","category-sjapp","tag-vscodeapk","tag-3348","tag-11","tag-81","tag-app"],"_links":{"self":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/21234","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/comments?post=21234"}],"version-history":[{"count":1,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/21234\/revisions"}],"predecessor-version":[{"id":21436,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/21234\/revisions\/21436"}],"wp:attachment":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/media?parent=21234"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/categories?post=21234"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/tags?post=21234"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/topic?post=21234"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}