记在新浪云SAE部署django项目成功时心得

1、关于新浪云SAE的环境类型(以python为例)

      新浪云SAE环境类型包括 “独享环境” 和 “共享环境”。

      根据使用情况总结:

(1)“共享环境”

        python语言版本固定,不可指定。比如:当前默认python版本是2.7,而你的项目又可以改成基于python2.7,那就可恭喜你了;如果你的项目不可以改成就python2.7,那就折腾吧,我就被折腾了好几个晚上。。。还是没有搞定(谁要是知道怎么解决,感激你能告诉我)。

       如果你的项目使用的django版本与环境不同(具体版本可度娘),可在项目使用django包方式解决。

(2)“独享环境” 

         “共享环境”是免费部署的,在此要感谢新浪,给广大开发者带来福音!!!

         “独享环境” 部署要付费,对于基础开发者来说,费用还是比较低的;毕竟是收费的,服务果然不同,少了很多折腾。可以轻松指定python版本、django版本以及其他依赖包。

2、部署及其遇到的问题

(1)基本过程参考:https://segmentfault.com/a/1190000004980818(例子中使用svn管理版本文件,我使用的是git)

(2)问题1(第一次提交版本git push):

以图为证:

remote: -----> $ python manage.py collectstatic --noinput
remote:        Traceback (most recent call last):
remote:        File "manage.py", line 15, in <module>
remote:        execute_from_command_line(sys.argv)
remote:        File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
remote:        utility.execute()
remote:        File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
remote:        self.fetch_command(subcommand).run_from_argv(self.argv)
remote:        File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
remote:        self.execute(*args, **cmd_options)
remote:        File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute
remote:        output = self.handle(*args, **options)
remote:        File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 188, in handle
remote:        collected = self.collect()
remote:        File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 114, in collect
remote:        handler(path, prefixed_path, storage)
remote:        File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 343, in copy_file
remote:        if not self.delete_file(path, prefixed_path, source_storage):
remote:        File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 249, in delete_file
remote:        if self.storage.exists(prefixed_path):
remote:        File "/app/.heroku/python/lib/python3.6/site-packages/django/core/files/storage.py", line 308, in exists
remote:        return os.path.exists(self.path(name))
remote:        File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 43, in path
remote:        raise ImproperlyConfigured("You're using the staticfiles app "
remote:        django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.
remote:
remote:        !     Error while running '$ python manage.py collectstatic --noinput'.
remote:        See traceback above for details.
remote:
remote:        You may need to update application code to resolve this error.
remote:        Or, you can disable collectstatic for this application:
remote:
remote:        $ heroku config:set DISABLE_COLLECTSTATIC=1
remote:
remote:        https://devcenter.heroku.com/articles/django-assets
remote: {"Code":1,"Error":"build image failed: exit status 1."}
remote: 错误:构建镜像失败
remote: error: hook declined to update refs/heads/master

解决方法1:

因为没有对setting.py设置STATIC_ROOT,解决如下:

STATIC_ROOT = os.path.join(BASE_DIR,'static')

参考:https://blog.csdn.net/qixu_yang/article/details/80415761

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值