A personalized project template for Django 1.6 using postgres for development and production. Ready to deploy on Heroku.
To use this project follow these steps:
- Create the new project using the django-two-scoops template
- Create dev and prod virtual environments
- Install dependences for both dev and prod
- Create postgres database for dev
- Create .env file for prod
- Run the project in dev
- Run the project in prod
- Deploy to Heroku
note: these instructions show creation of a project called "icecream". You should replace this name with the actual name of your project.
Prerequisites: python, pip, django
To create a new Django project called 'icecream' using django-twoscoops-project, run the following command:
$ django-admin.py startproject --template=https://github.com/imkevinxu/django-twoscoops-project/archive/master.zip --extension=py,md,bat,html --name=Procfile,Makefile icecream
Prerequisites: virtualenv, virtualenvwrapper
$ cd icecream
$ mkvirtualenv icecream-dev && add2virtualenv `pwd` && deactivate
$ mkvirtualenv icecream-prod && add2virtualenv `pwd` && deactivate
For development:
$ deactivate && workon icecream-dev
$ pip install -r requirements/local.txt
For production:
$ deactivate && workon icecream-prod
$ pip install -r requirements.txt
note: We install production requirements this way because many Platforms as a Services expect a requirements.txt file in the root of projects.
Prerequisites: Postgres
Install Postgres for your OS here. For Max OSX the easiest option is to download and run Postgres.app.
$ createdb icecream
The SECRET_KEY for production is not version controlled so the first person to create this project needs to create a .env file for Foreman and Heroku to read into the environment. Hacky use of date | md5
to generate a pseudo-random string.
.env is not version controlled so future collaboraters need to email the creator for it.
$ echo "SECRET_KEY=`date | md5`" >> .env
Be in the same directory as manage.py
.
$ deactivate && workon icecream-dev
$ python manage.py runserver
Prerequisites: Heroku Toolbelt
Be in the same directory as Procfile
.
$ deactivate && workon icecream-prod
$ cd icecream && python manage.py collectstatic --noinput && cd ..
$ foreman start
Prerequisites: heroku-config
$ git init
$ git add .
$ git commit -m "ready for heroku deploy"
$ heroku create
$ heroku config:push
$ git push heroku master
$ heroku ps:scale web=1
$ heroku open
- Syncdb instructions
- Database migration instructions
This project follows best practices as espoused in Two Scoops of Django: Best Practices for Django 1.6.
- Many thanks to Randall Degges for the inspiration to write the book and django-skel.
- All of the contributors to this project.