[Answered ]-Why are there one model.py per app instead of just one model.py out through the whole project?

1👍

So that the apps can be taken and used with a different database if desired without needing to modify the code (much).

1👍

Django is set up to have projects that are collections of reusable, self contained apps. Each has its own model.py because they’re tied closely to the views and templates for that app but may not be needed for the rest of the project.

👤JAL

0👍

Ususally you will start writing one app. Once in a time, you will recognize that there are features which are not very tightly related (e.g. user management or different sub-parts). Additionally, your models.py will start to be lengthy and want to have a clearer structure.
This is the point in time where you start splitting your project in independent sub-parts – the apps. Still, they will work with the same database. And even better: some friendly guys might have built apps whih you can include in your project – each bringing teir models and – of course – interacting with your database.
If everything in yourproject is closely related, there is no need for different apps.

👤OBu

Leave a comment