Skip to content
Example project layout for a new Django project (currently targets 1.5)
Python

README.md

django-example-project

  • Demonstrates best practices I have learned with my time spent working with Django.
  • Currently targets Django 1.5.

Features

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

Installation

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.

  1. Create a virtual environment mkvirtualenv django-example-project
  2. Clone this repository git clone git@github.com:RyanBalfanz/django-example-project.git
  3. From within the repository root, install project dependencies pip install -r requirements.txt

Usage

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.

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).

Something went wrong with that request. Please try again.