Django Heroku Starter
These instructions will get you a copy of the project up and running on your local machine for development purposes. See deployment for notes on how to deploy the project on a live system.
What things you need to install and how to install them.
For MAC OS: I recommend Homebrew for installing and managing applications on MacOS. It is installed using the following command in the MacOS terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Distributed version-control system for tracking changes in source code during software development.
# MAC OS
brew install python
# WINDOWS
https://www.python.org/downloads/windows/
- PostgreSQL
# MAC OS
brew install postgresql
After it finished, run:
brew services start postgresql
# WINDOWS
http://www.enterprisedb.com/thank-you-downloading-postgresql?cid=48
Setting Windows PATH for Postgres tools:
https://sqlbackupandftp.com/blog/setting-windows-path-for-postgres-tools
- Virtual Environtment
MAC OS - Virtualenvwrapper
pip install virtualenvwrapper
WINDOWS - virtualenvwrapper-win
pip install virtualenvwrapper-win
A step by step series of examples that tell you how to get a development environment running
- Create virtual environment on your local computer
# MAC OS:
mkvirtualenv --python=`which python3` VIRTUAL_ENV_NAME
# WINDOWS:
mkvirtualenv VIRTUAL_ENV_NAME
# Activate it
workon VIRTUAL_ENV_NAME
- Install django project requirements
pip install -r requirements.txt
- Setup local postgres database
createdb DATABASE_NAME
createuser USER_POSTGRES_NAME
psql kardus
ALTER USER kardus WITH ENCRYPTED PASSWORD USER_POSTGRES_PASSWORD;
- Setup local_settings.py
# Duplicate or rename local_settings.py.example to local_settings.py.
# Replace it with your DATABASE_NAME, USER_POSTGRES_NAME, and USER_POSTGRES_PASSWORD
- Migrate database
python manage.py migrate
- Create Superuser
python manage.py createsuperuser
- Run web locally
python manage.py runserver
Additional notes about how to deploy this on a live system.
- Create a Procfile in project root.
# Replace dj_heroku with your project name
web: gunicorn dj_heroku.wsgi
- Install psycopg2
# for MAC OS only :
pip install psycopg2==2.7.5
-
Install Heroku-CLI
-
Commit changes.
git add .
git commit -m 'Ready to deploy heroku'
- Setup Heroku app
# Login to your heroku account
heroku login
# Create new app
heroku create APP_NAME
# Create a new heroku postgres database
heroku addons:create heroku-postgresql:hobby-dev
- Add secret_key to heroku apps
# Copy SECRET_KEY in settings.py to Heroku app settings.
- Deploy
# Push to master
git push heroku master
# Migrate database to heroku app
heroku run python manage.py migrate