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:
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.).
I also use relative imports from within the “apps” directory:
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.).