UPDATE: This article was originally written when Django version was 1.4. Since this article was published I made changes based on the new features of Django. You can see some of them in this repository: https://github.com/jackboot7/django-project-template.
This is short entry on how I organize my Django projects, in a way that will be easy to deploy to a production server. This is not meant to be a full tutorial on Django, but just to document the way I layout my Django applications. I consider this layout a work in progress, as each day I learn something new that I can integrate into my project's layout. Anyway, I hope someone else can find this entry useful.
For most of my small/pet/side projects, I use a simple server schema, working only with a local development machine and a production server, I know that is a good practice to use a staging server with the same setup as the production server, but for small projects I found this unnecessary.
First, let me show you the layout of most of my projects:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| - project_domain_name/ | | - .gitignore (.hgignore ) | | - requirements.pip | | - env/ # Virtual enviroment. | | - var/ | | - server_config/ # Server configuration files. | | | - nginx.conf | | | - uwsgi.ini | | | | | - server_logs/ # Server logs. | | | - errors.log | | | - access.log | | | | | - project_dir/ # Django project. Most of the time I name it 'webapp' | | | - apps/ # Application apps. | | | - templates/ | | | - static/ | | | - manage.py | | | - urls.py | | | - settings.py | | | - local_settings.py
Some of this files and dirs are meant to be ignored by the control version system.
*local_settings.py*, for every local development machine, there should be a local settings file, this is where you put all the local development settings such as …