Alcides Fonseca

40.197958, -8.408312

Django Layout

One of the things I don’t like about django is the lack of a decent project folder structure. I know it’s a good thing its flexibility, but the default one is really awkward. There are several problems with it:

  • Lack of a default layout for different environments (development, testing, production, and yours).
  • Settings require the full path to media directory, and there is no default place.
  • I like templates to be at the app-level instead of project-level.

And a few more I’m not remembering now.

To solve these problems, I created a django default template for my projects with my conventions, that you can use or fork to adapt to your own if you want. I could go with a more fancy solution for the environments, but since I don’t have a testing server, the settings-prod works pretty fine. Other option is to check sys.uname to see if it’s running in the production server or not.

Since I got my own VPS, I’ve been deploying django using passenger (including this wiki) and it’s working pretty fine, so I am now using the passenger branch of the layout.