Last active
January 2, 2016 20:48
-
-
Save diverted247/8358906 to your computer and use it in GitHub Desktop.
0 to Django environment running local and remote on HerokuRequires: Python 2.7+, Heroku-Toolbelt, Git$ source django_new.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| echo "Project Name? " | |
| read project_name | |
| echo "Creating: $project_name" | |
| mkdir $project_name && cd $project_name | |
| mkvirtualenv $project_name | |
| pip install django | |
| pip install psycopg2 | |
| pip install gunicorn | |
| pip install dj-database-url | |
| pip install dj-static | |
| pip install south | |
| django-admin.py startproject $project_name . | |
| echo "web: gunicorn $project_name.wsgi" > Procfile | |
| pip freeze > requirements.txt | |
| git init | |
| #heroku init | |
| heroku create $project_name | |
| #heroku db | |
| heroku addons:add heroku-postgresql:dev | |
| heroku pg:wait | |
| db_name=${db_data%%:*} | |
| heroku pg:promote $db_name | |
| echo "venv | |
| .env | |
| *.pyc | |
| staticfiles" > .gitignore | |
| echo " | |
| # Parse database configuration from $DATABASE_URL | |
| import dj_database_url | |
| DATABASES['default'] = dj_database_url.config() | |
| # Honor the 'X-Forwarded-Proto' header for request.is_secure() | |
| SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') | |
| # Allow all host headers | |
| ALLOWED_HOSTS = ['*'] | |
| # Static asset configuration | |
| import os | |
| BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | |
| STATIC_ROOT = 'staticfiles' | |
| STATIC_URL = '/static/' | |
| STATICFILES_DIRS = ( | |
| os.path.join(BASE_DIR, 'static'), | |
| )" >> $project_name/settings.py | |
| echo " | |
| from django.core.wsgi import get_wsgi_application | |
| from dj_static import Cling | |
| application = Cling(get_wsgi_application())" >> $project_name/wsgi.py | |
| git add . | |
| git commit -m "$project_name first commit" | |
| git push heroku master | |
| heroku run python manage.py syncdb | |
| heroku open | |
| heroku config:pull --overwrite --interactive | |
| foreman start |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requirements:
Python & pip & virtualenv
virtualenvwrapper - pip install virtualenvwrapper
herokutoolbelt - https://toolbelt.heroku.com/
Run:
source django_new.sh