问题
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
piprequirements listed inrequirements.txt - Relaunches the "dyno" web server by invoking
python manage.py runserveron 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-pipsudo pip install virtualenvwrappersudo pip install autoenvcd path/to/projectmkvirtualenv venv_name_hereecho "source /home/your_username/.virtualenvs/venv_name_here/bin/activate" >> .envcd .python manage.py syncdbpython manage.py runserver 0.0.0.0:8000
来源:https://stackoverflow.com/questions/26317355/how-to-create-make-your-app-local-with-heroku-virtualenv-django