Reputation: 41665
Suppose you are building a Google website. (ok big dream)
Google has web search/youtube/email/news/etc ..
For this site, I'd like to structure my django directory like
Google/
search
youtube
email
news
and so on.
How do I structure such a site?
Create an app for each even though I'm not expecting to publish any of the category as an app?
Where would a common stuff (such as user model, utility modules, decorators..) would go, create a common_app?
Upvotes: 1
Views: 374
Reputation: 2143
Applications are reusable components for a django project that revolve around a central purpose. Applications don't need to map directly to your url structure of the website. While there is a standard structure for a django application to tie in with some of the management commands, such as tests.py
, models.py
, static files at /static/
you don't need to have any of it to be an application. For example, South is a popular django application used to provide database migrations. It adds a few management commands to manage.py
.
When you are adding functionality and it doesn't map directly to the purpose of the application, just create a new one. So instead of thinking of it a a common_app, think about what the purpose of the application would be and how it might be utilized by your other applications.
In my projects, I tend to create a base
application to handle the base template and static assets that are used in the base template. I'll create an accounts
application to handle the user model and implement things like password reset. To deal with global notifications from any part of my site, I'll create an alerts
application. The list can go on for a lot of the common functionality, but it's grouped in a way that revolves around a function and written as if it would be distributed.
So, in your specific case, you'll likely have at least an application for each of the domains such as search
, youtube
, email
, and news
, but also an application for each common component you might want to use across your core domains.
Upvotes: 1