# Environment Structure for Django Apps

DevFeed: [Environment Structure for Django Apps](<https://devfeed.tech/articles/environment-structure-for-django-apps-41100.md>)

Original publisher: [Read original article](<https://www.craigkerstiens.com/2011/05/16/Environment-Structure-for-Django-Apps/>)

Author: Map

Published: 2011-05-17T03:55:56Z

Content type: tutorial

Language: en

Sources: [Craig Kerstiens](<https://devfeed.tech/sources/craig-kerstiens.md>)

Topics: [Django](<https://devfeed.tech/topics/django.md>), [Development](<https://devfeed.tech/topics/development.md>), [Python](<https://devfeed.tech/topics/python.md>), [PostgreSQL](<https://devfeed.tech/topics/postgresql.md>), [Git](<https://devfeed.tech/topics/git.md>), [osx](<https://devfeed.tech/topics/osx.md>), [Ubuntu](<https://devfeed.tech/topics/ubuntu.md>)

Tags: [development](<https://devfeed.tech/tags/development.md>), [development-environment](<https://devfeed.tech/tags/development-environment.md>), [django](<https://devfeed.tech/tags/django.md>), [git](<https://devfeed.tech/tags/git.md>), [osx](<https://devfeed.tech/tags/osx.md>), [postgresql](<https://devfeed.tech/tags/postgresql.md>), [python](<https://devfeed.tech/tags/python.md>), [setup](<https://devfeed.tech/tags/setup.md>), [things](<https://devfeed.tech/tags/things.md>), [ubuntu](<https://devfeed.tech/tags/ubuntu.md>)

## AI overview

A cookbook for structuring Django project environments on OSX and Ubuntu. It explains how to create a Python virtual environment, install Django and PostgreSQL dependencies, use requirements.txt and .gitignore, and prepare a repository for contributors.

## Source excerpt

I've been writing applications off and on for nearly 4 years now, since before Django 1.0 was even released. I must say the framework could not be better described than by its own tagline "The Web framework for perfectionists with deadlines". Among the things I love about it are: However, after using the framework for nearly 4 years I'm just now discovering my preferred way of managing environments. I know there's still a bit of back and forth on development environment/IDE, but as far as configuring actual project environment I've become very comfortable with what I've now been using for many months. It also allows for someone else bootstrapping their environment incredible quickly as well. Below is a quick cookbook of how to do this on OSX and Ubuntu. $ sudo port install python27 $ sudo port install py27-virtualenv $ sudo port install postgresql90 Now for setting up your project: $ mkdir example $ cd example $ virtualenv-2.7 --no-site-packages . $ source bin/activate $ sudo brew install python $ sudo brew install virtualenv $ sudo brew install postgresql Now for setting up your project: $ mkdir example $ cd example $ virtualenv --no-site-packages . $ source bin/activate $ sudo aptitude install python sudo aptitude install virtualenv sudo aptitude install postgresql Now for setting up your project: $ mkdir example $ cd example $ virtualenv --no-site-packages . $ source bin/activate For those of you not familiar virtualenv is a self-contained python environment. It holds its own copy of python and any libraries you install. Now that you've setup your virtualenv we can go through the process of installing django and setting up your repository. This is the same across all of the above platforms: Add to a .gitignore file: bin build include lib .Python *.pyc Add to a requirements.txt file: Django==1.3.1 psycopg2==2.4.1 Then run: $ bin/pip install -r requirements.txt This should fully installed any of your required apps and makes it easy for others to do the same to begi