当前位置: 移动技术网 > IT编程>脚本编程>Python > SAE Django框架python应用部署及独享服务器

SAE Django框架python应用部署及独享服务器

2017年12月22日  | 移动技术网IT编程  | 我要评论

sait-011,绥靖的意思,我的刑警朋友

在阅读Python 应用部署指南之后,打算自己搭建Django的app。在此记录过程中是遇到的一些坑,主要是push到SAE的过程出现的错误

个人SAE云应用的配置
这里写图片描述

1.在git push origin master时git提示错误:
 raise ImproperlyConfigured("You're using the staticfiles app ") django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path

git的错误提示很友好,附上了一个参考链接:
根据链接的知道修改了需要setting文件的配置
这里写图片描述

2. 再次git push origin master,出现错误
Error while running '$ python manage.py collectstatic --noinput'

查看链接发现如下解释:
Older versions of Django won’t automatically create the target directory (STATIC_ROOT) that collectstatic uses, if it isn’t available. You may need to create this directory in your codebase, so it will be available when collectstatic is run. Git does not support empty file directories, so you will have to create a file inside that directory as well.

简单的说,在构建程序的过程中,我们需要创建一个staticfiles文件夹。而且如果改文件夹为空,git add是无法加入到缓存区的。因此我们必须在staticfiles文件夹中放入一个文件(这个非常重要,被卡到心酸)

经过以上操作,git push origin master终于没有出现错误

4、登录网址

提示错误:502 Bad Gateway
查找资料说是网关错误。解决思路是Profile文件的设置问题

Before:
web: python manage.py runserver

After:
web: python manage.py runserver 0.0.0.0:5050

为什么是0.0.0.0:5050呢?
我参考了应用程序运行

这里写图片描述

5. 再次登录应用地址

提示错误:
这里写图片描述

查找资料后,解决办法,修改settings文件下的配置

before:
ALLOWED_HOSTS = []

After:
ALLOWED_HOSTS = ['*']

经过上面的努力,终于运行成功
这里写图片描述

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网