Django site architecture

81 views Asked by At

When you are busy developing an app, it is sometimes easy to get carried away and write many many models, somewhat related. Then, the question is how to layout the website given all the models. Say you have the following models:

models: M1, M2, ..., M60

You then come to realize you can divide them into apps:

apps: AP1, AP2, ..., AP12

Then, after a while you might realize you have different projects, with different databases, business logic, target audience, etc. (e.g. a site that has lodging, skiing, equipment rental, eCommerce, etc. all under one site)

projects: P1, P2, P3

The question is if it is better to have semantically unrelated apps within one project or group related apps under separate projects?

Site
|
P1 - P2 - P3
|    ...
----------------
|    |    |    |
AP1  AP2  AP3  AP4
|    ...
---------------------
|    |    |    |    |
M1   M2   M3   M4   M5

OR:

Site
|
Solo_Project
|
----------------
|    |    |    |
AP1  AP2  AP3  AP4
|    ...
---------------------
|    |    |    |    |
M1   M2   M3   M4   M5

If the former, then how should one have a meta settings.py to specify the ROOT_URLCONF and all other settings that the settings.py usually take care of (database routing, etc.)

Other than Django docs, I found Django tips: layout out an application useful (yet insufficient) readings.

1

There are 1 answers

0
wobbily_col On

Its very subjective.

I think my rule would be that if it provides a set of functionality that can be used independently of the other parts then put it in a separate app.

One of my previous projects had one big app, (plus a shopping cart type feature that I added as a separate app). I thought about splitting the main app up, but a lot of queries and views used all the tables, so in the end I decided it made more sense as one large app, rather than splitting it into multiple apps with no clear distinction in functionality.