简体   繁体   English

在Heroku中首次推送django

[英]First push django in heroku

I'm trying to push my django app in heroku and I've followed all the instructions in the tutorial of heroku's page, but when i try to do the push i get this: 我正在尝试在heroku中推送我的django应用程序,并且已经按照heroku页面的教程中的所有说明进行操作,但是当我尝试进行推送时,我得到了以下信息:

christian@christian-R480-R431-R481:~/Documentos/heroku/Portafolio6$ sudo git push heroku master
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 542 bytes, done.
Total 5 (delta 0), reused 0 (delta 0)


 !     Push rejected, no Cedar-supported app detected

To git@heroku.com:mysterious-thicket-1865.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:mysterious-thicket-1865.git'
christian@christian-R480-R431-R481:~/Documentos/heroku/Portafolio6$ 

I dont know why this happens. 我不知道为什么会这样。 Do I have to do the push in the django project or when i have the virtualenv folder? 当我有virtualenv文件夹时,是否必须在django项目中进行推送?

Do you have a valid requirements.txt file? 您是否有一个有效的requirements.txt文件? This file is needed by Heroku to pip install the relevant python packages that your app uses. Heroku需要此文件来pip安装您的应用程序使用的相关python软件包。

To auto generate this file, just run the following code: 要自动生成此文件,只需运行以下代码:

pip freeze > requirements.txt

The requirements.txt file should reside at the top most level, adjacent to the app. requirements.txt文件应位于最顶层,与应用程序相邻。

The 'Step 3 - Heroku Best Practices' section at http://www.deploydjango.com/django_project_structure/ will give you more info. http://www.deploydjango.com/django_project_structure/上的“第3步-Heroku最佳做法”部分将为您提供更多信息。

Check that you have the requirements.txt, Procfile and runtime.txt files in your directory. 检查您的目录中是否具有requirements.txt,Procfile和runtime.txt文件。

To generate requirements.txt, activate your virtualenv and freeze the installed packages: 要生成requirements.txt,请激活您的virtualenv并冻结已安装的软件包:

workon my_project
pip freeze > requirements.txt

Your Procfile is responsible for telling the heroku system how to run your app (and most likely is what is missing in this instance). 您的Procfile负责告诉heroku系统如何运行您的应用程序(并且很可能是此实例中缺少的内容)。 Here is a sample: 这是一个示例:

web: gunicorn my_project.wsgi -b 0.0.0.0:$PORT

Your runtime.txt file is responsible for determining which version of python to run: 您的runtime.txt文件负责确定要运行的python版本:

python-2.7.4

Ensure that all three files exist (technically runtime.txt is optional, but it's a good idea), are commited and then try your push again. 确保所有三个文件都存在(从技术上来说,runtime.txt是可选的,但这是个好主意),已提交,然后再次尝试推送。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM