How to create/make your app LOCAL with Heroku/Virtualenv/Django?

此生再无相见时 提交于 2020-01-03 05:07:07

问题


Here's what i've done so far:

  • Installed Git Bash and Heroku, and Foreman.
  • Logged in, created a key, etc...
  • Cloned a demo app from Git.
  • Deployed/Tested it on the browser. It works.

I'm working on this directory:

*/python-getting-started (master)*


Which has this stuff:
Procfile
gettingstarted
manage.py
runtime.txt
README.md
**hello ( My app)**
requirements.txt

Well, by the files are named (init, manage.py, stuff like that...) i assume Django is hosted on the remote machine (Heroku Machine?)... And when it comes to running the app locally, i'm not sure how to use virtualenv to do that.....

Should i "set" virtualenv inside the remote folder? If that's correct, what's the point? I could just use python itself without need for virtualenv...

I'm not sure if my question is making any sense, if you need to know any other thing please... Been trying to set up this for two days now...


回答1:


A git push heroku_remote_name local_branch_name:master call will push that branch of code to Heroku. Heroku then does the following...

  • Pulls in code changes
  • Installs pip requirements listed in requirements.txt
  • Relaunches the "dyno" web server by invoking python manage.py runserver on the remote web server.

If you want to run the web application locally, you will want to create a virtualenv and invoke python manage.py runserver locally.

If you are on linux, here are a bunch of commands that should have you working smartly. If you're not on linux, the steps should at least be illustrative of what you will want to do.

  • sudo apt-get install -y python-pip
  • sudo pip install virtualenvwrapper
  • sudo pip install autoenv
  • cd path/to/project
  • mkvirtualenv venv_name_here
  • echo "source /home/your_username/.virtualenvs/venv_name_here/bin/activate" >> .env
  • cd .
  • python manage.py syncdb
  • python manage.py runserver 0.0.0.0:8000


来源:https://stackoverflow.com/questions/26317355/how-to-create-make-your-app-local-with-heroku-virtualenv-django

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!