【问题标题】:Error during deploying django app in Heroku在 Heroku 中部署 django 应用程序时出错
【发布时间】:2021-04-28 11:18:00
【问题描述】:

我正在尝试将 Django 应用程序部署到 Heroku。当我按照文档尝试命令git push heroku master 时,我得到了error: failed to push some refs to 'https://git.heroku.com/sleepy-eyrie-25993.git'。我在网上搜索并尝试使用git pull。但它没有用。我也尝试使用git push -f heroku master,但仍然遇到同样的错误。还有其他方法吗?我跟着这个文档 https://devcenter.heroku.com/articles/python-support。 尝试使用heroku仪表板,但它给出了同样的错误 Building on the Heroku-18 stack ! No default language could be detected for this app. HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically. See https://devcenter.heroku.com/articles/buildpacks ! Push failed

【问题讨论】:

    标签: django git heroku deployment


    【解决方案1】:

    Heroku 部署需要存储库根目录中的 requirements.txt。 此外,要运行 Django 应用程序 - 它需要文件 Procfile

    示例内容:

    web: gunicorn your_app_name.wsgi:application --log-file -
    

    你也可以尝试通过执行手动指定buildpack:

    heroku buildpacks:set heroku/python
    

    如果有其他错误开始 - 它们会更具体

    您的 Django 应用程序的 settings.py 还应包含以下内容:

    import django_heroku
    
    django_heroku.settings(locals())
    

    更多详情请参考Here

    【讨论】:

    • 我指定了构建包。如何创建Procfile
    • 它只是一个没有扩展名的纯文本文件,名称为Procfile,您可以使用任何文本编辑器复制粘贴我在上面发布的 gunicorn 命令
    【解决方案2】:

    您还可以从 Heroku 上的应用程序仪表板进行部署

    【讨论】:

    • 以及如何做到这一点。你能解释一下吗?
    • 访问dashboard.heroku.com,然后选择new并创建一个新应用,创建应用后选择connect to GitHub并搜索应用,选择应用后会看到选项部署一个 GitHub 分支。
    • 刚刚尝试使用仪表板,但再次出现同样的错误。
    • 您可以从仪表板添加构建包,选择设置,然后单击添加构建包
    • 应该为static 添加什么。我们是否需要添加一个名为static的目录
    猜你喜欢
    • 2017-09-20
    • 2018-02-09
    • 2015-10-09
    • 2019-06-25
    • 2018-12-25
    • 2013-07-04
    • 1970-01-01
    • 2021-05-16
    相关资源
    最近更新 更多