4 ms·
Whenever I start a new Django / Python project I come up with a short and generic(ish) internal name, like “pluto” - then, the repo is structured like this:
by gonational 7y ago
Whenever I start a new Django / Python project I come up with a short and generic(ish) internal name, like “pluto” - then, the repo is structured like this:
README.md
runtime.txt
requirements.txt
pluto
wsgi.py
manage.py
urls.py
- conf
- common.py
- prod.py
- local.py
- static
- templates
- apps
- accounts
- models.py
- etc
- users
- etc
In a case like this, the repo is named “pluto” in GitHub, but I clone it as “src”; so, the project locally looks like this:
pluto
\ src
\ pluto
I CD to the root (pluto/src) and work from there.
I also use relative imports from within the “apps” directory:
# e.g., inside pluto/apps/accounts/views.py
from ..users.models import User
I’ve used this pattern for years now. It feels so much cleaner than any other pattern I’ve ever used, and it also makes my projects much more reusable (if I want to copy my latest project as a skeleton for the next, etc.).