marco
marco

Reputation: 351

What are the advantages/disadvantages when splitting related models into separate apps in Django

I'm currently in the process of learning Django by creating a simple web app that models a toy store. Currently, I have 3 apps in my Django project: Toy, Details, and Store, each with its own model. Toy and Details are mutually exclusive, while Store is composed of a Toy and Detail, along with other attributes. Should I consolidate all 3 apps into 1 application, or is there a benefit for having them separated?

Just as a note: I am planning on communicating with Django purely through REST API Calls from the frontend.

Upvotes: 3

Views: 1059

Answers (1)

DanielM
DanielM

Reputation: 4043

This is mostly opinion-based, there is no right or wrong as long as you understand your project structure. There is a nice discussion here about it.

In terms of pros/cons:

  • If you are the only developer on the project, splitting into different apps will probably slow down your development because of several reasons (e.g., same package names which you need to import). However, if you are willing to put in the extra effort required to keep the apps decoupled, it will allow you to introduce later changes easily.
  • On the flip side, if you are not the only developer, dividing the work will be easier with multiple apps.
  • Splitting into different apps will allow you to reuse the apps for different projects (Maybe Details in your project can be used not only for Store?). It might also allow you to publish it as a django-package.
  • If you wish to have the ability to turn features on/off (because you sell your project and have several tiers with different features, etc.) - splitting into apps will enable you to do it easily (just have different settings files with different INSTALLED_APPS)

Upvotes: 2

Related Questions