DEV Community

Cover image for Django Project Structure Best Practice

Django Project Structure Best Practice

courseprobe profile image Course Probe ・4 min read

Let’s explore some recommendations to keep the best structure for a Django example, please share yours in the comments below.

There’s no right or wrong way to put in place django project layout or app structure, so we are trying to provide some examples for those learning django and also to get some suggestions from more experienced developers on what they consider as best practice for a django project file structure.

Stand-alone website

Mostly private projects, but doesn’t have to be. It usually looks like this:


docs/               # documentation
scripts/         # installed to PATH via
project_name/       # project dir (the one which creates)
  apps/             # project-specific applications
    accounts/       # most frequent app, with custom user model
  settings/         # settings for different environments, see below
    ...       # contains project version
static/             # site-specific static files
templates/          # site-specific templates
tests/              # site-specific tests (mostly in-browser ones)
tmp/                # excluded from git
Enter fullscreen mode Exit fullscreen mode


The main settings are production ones. Other files (eg., simply import everything from and override only necessary variables.

For each environment, there are separate settings files, eg. production, development. I some projects I have also testing (for test runner), staging (as a check before final deploy) and heroku (for deploying to heroku) settings.


I rather specify requirements in directly. Only those required for development/test environment I have in requirements_dev.txt.

Some services (eg. heroku) requires to have requirements.txt in root directory.

Useful when deploying project using setuptools. It adds to PATH, so I can run directly (anywhere).

Project-specific apps

I used to put these apps into project_name/apps/ directory and import them using relative imports.

Templates/static/locale/tests files

I put these templates and static files into global templates/static directory, not inside each app. These files are usually edited by people, who doesn’t care about project code structure or python at all. If you are full-stack developer working alone or in a small team, you can create per-app templates/static directory. It’s really just a matter of taste.

The same applies for locale, although sometimes it’s convenient to create separate locale directory.

Tests are usually better to place inside each app, but usually there is many integration/functional tests which tests more apps working together, so global tests directory does make sense.

Tmp directory

There is temporary directory in project root, excluded from VCS. It’s used to store media/static files and sqlite database during development. Everything in tmp could be deleted anytime without any problems.


I prefer virtualenvwrapper and place all venvs into ~/.venvs directory, but you could place it inside tmp/ to keep it together.

Project template

I’ve created project template for this setup, django-start-template


Deployment of this project is following:

source $VENV/bin/activate
export DJANGO_SETTINGS_MODULE=project_name.settings.production
git pull
pip install -r requirements.txt

# Update database, static files, locales syncdb  --noinput migrate collectstatic --noinput makemessages -a compilemessages

# restart wsgi
touch project_name/
Enter fullscreen mode Exit fullscreen mode

You can use rsync instead of git, but still you need to run batch of commands to update your environment.

Recently, I made django-deploy app, which allows me to run single management command to update environment, but I've used it for one project only and I'm still experimenting with it.

Sketches and drafts

Draft of templates I place inside global templates/ directory. I guess one can create folder sketches/ in project root, but haven't used it yet.

Pluggable application

These apps are usually prepared to publish as open-source. I’ve taken example below from django-forme


Enter fullscreen mode Exit fullscreen mode

It is important to provide README and, so package is easily installed through pip.

Recommended Resources:

Get the Book: Django web development


Other Dev posts you might like:

Discussion (0)

Editor guide