- 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
mkvirtualenv django-example-project
- Clone this repository
git clone [email protected]:RyanBalfanz/django-example-project.git
- From within the repository root, install project dependencies
pip install -r requirements.txt
Once you have cloned this repository, you can run the example project with either Foreman or Supervisor. Either approach is fine.
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.
Foreman goes well with Heroku. To run the application with Foreman simply run foreman start
in the repository root (where the Procfile lives).
Alternatively, to run the application with Supervisor simply run supervisord
in the repository root (where the supervisord.conf file lives).