Anatomy of A Django app
Bringing a team to common grounds is vital. Good coordination needs to follow some rules. Aside from these rules, each coder can go wild and let his ideas fall in place to form an end goal.
Django provides a great environment for team developing. So for a common base, all the apps must follow a certain anatomy. I’ll explain here the anatomy I have in mind.
Notes:
- directories are in bold
- all the text in italics is just for explanation
myApp - the main app diretory
templates - folder that contains all the templates. It’s put here, inside the app directory for a quicker navigation and for better decoupling
__init__.py - marker of a Django app
forms.py - holds all the forms called by views.py
models.py - all the models from this app
urls.py - urls that are called by this app, for good decoupling
utils.py - functions used inside this app. Everything that doesn’t fit in views.py, forms.py and models.py. This library can be just imported when needed, for efficiency. Can be called helpers.py too.
views.py - holds classes and functions which render templates. I emphasize: render templates. Sure, it can combine forms and stuff from utils.py but the end goal should be to render a template.
I know, I know. This maybe works for small to medium size apps. If you get a better idea for bigger ones, sound out.