- Demonstrates best practices I have learned with my time spent working with Django.
- Currently targets Django 1.5.
This repository demonstrates:
- Repository-level layout and organization
- Project-level layout and organization
- Gunicorn WSGI HTTP Server
- Procfile-based process management with Foreman, which is great for deploying to Heroku
- Supervisor based process management
This process assumes a basic knowledge of the Python ecosystem. If you are unfamilliar with Pip, Virtualenv and it's counterpart Virtualenvwrapper, and the like, you may want to do some initial research into those topics.
- Create a virtual environment
- Clone this repository
git clone firstname.lastname@example.org:RyanBalfanz/django-example-project.git
- From within the repository root, install project dependencies
pip install -r requirements.txt
I've found that Supervisor works great for local development where you have multiple processes to manage (usually a database such as PostgreSQL or MySQL) in conjunction with the Django Python process. I usually use a managed database solution such as Heroku Postgres or Amazon RDS for staging and production deployments, and a local install for my local development.
The choice is, obviously, up to you. Not being able to blow away your entire staging database as easily as
rf -rf ./db or whatever is a best practice in my experience because it forces you to use migrations and be thoughtful about how to treat your database.
Running with Foreman
Foreman goes well with Heroku. To run the application with Foreman simply run
foreman start in the repository root (where the Procfile lives).
Running with Supervisor
Alternatively, to run the application with Supervisor simply run
supervisord in the repository root (where the supervisord.conf file lives).