Django Model Inheritance to multiple apps

Viewed 110
class People(models.Model):

    # Utility Fields - auto fill

    # Timestamp

    # Base Fields
    
    # Methods, e.g save, get_absolute_url

    class Meta:
          abstract = True
  • App clients: inherit from People model + its own Fields
  • App vendors: inherit from People model + its own Fields

Questions

  • Q1: Where should I place the code for the People model, since I want to use it for more than 2 apps?
  • Q2: Is this practice acceptable?
  • Q3: Will it work in a production environment efficiently?
1 Answers

Q1: Where should I place the code for the People model, since I want to use it for more than 2 apps?

Just create a third app for abstract models. It's fine.

Q2: Is this practice acceptable?

Yes. abstract = True is just intended for this.

Q3: Will it work in a production environment efficiently?

Yes, also, abstract = True does not create new db tables or relations, is just code.

Related