This is what I need for my project, I've been figuring out decent ways to avoid duplication of model content to each and every content I make in my project. Thanks you!
Thanks for commenting. Yes, you may have multiple different types of products, each with their own fields. But there may be a common set of fields that you can define on a base class (this could be an abstract model, or you could go with the multi-table inheritance approach). For example, all products would have a "price", so it makes sense to use this on a base class. But certain products may have different, specific fields. A clothing product may have fields such as "size", whereas a food/drink product may have fields such as "calories". These would belong in the subclasses. I hope that makes sense!
I used field created_at and updated_at in CommonField class and inherited but how do i make sure that the created_at and updated_at columns are at last of the table because when i inherited it, it comes at first of the table.
This is what I need for my project, I've been figuring out decent ways to avoid duplication of model content to each and every content I make in my project. Thanks you!
Nice one, thank you for the comment!
thanks man. Learned something new.
Nice one man, thanks for commenting!
Beautifully explained. Well done.
Thank you very much!
aweome, very clear!
Thank you!
Thank you
Thanks for watching!
Thank you!
Thanks a lot for watching!
It would be cool if you could make a video about using composition in Django 💪
An issue with Multiple Inheritance is that you can have a performance hiy if your database is too large, because in has to make joins for every query.
Hi Bugbytes, thanks for this new video. Can this model inheritance be used in product variation of an eccommerce? If yes, how?
Thanks for commenting.
Yes, you may have multiple different types of products, each with their own fields. But there may be a common set of fields that you can define on a base class (this could be an abstract model, or you could go with the multi-table inheritance approach).
For example, all products would have a "price", so it makes sense to use this on a base class.
But certain products may have different, specific fields. A clothing product may have fields such as "size", whereas a food/drink product may have fields such as "calories". These would belong in the subclasses.
I hope that makes sense!
❤️👌
Thanks! 😄
I used field created_at and updated_at in CommonField class and inherited but how do i make sure that the created_at and updated_at columns are at last of the table because when i inherited it, it comes at first of the table.