Django Model Inheritance - Abstract Models and Multi-Table Inheritance

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ก.ย. 2024

ความคิดเห็น • 19

  • @richardalcantara3495
    @richardalcantara3495 2 ปีที่แล้ว +2

    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!

    • @bugbytes3923
      @bugbytes3923  2 ปีที่แล้ว

      Nice one, thank you for the comment!

  • @stevepole1970
    @stevepole1970 2 ปีที่แล้ว +1

    Beautifully explained. Well done.

  • @DemelashShimekit
    @DemelashShimekit 2 หลายเดือนก่อน +1

    Thank you

    • @bugbytes3923
      @bugbytes3923  2 หลายเดือนก่อน

      Thanks for watching!

  • @alaminbijoy1027
    @alaminbijoy1027 2 ปีที่แล้ว +1

    thanks man. Learned something new.

    • @bugbytes3923
      @bugbytes3923  2 ปีที่แล้ว

      Nice one man, thanks for commenting!

  • @chaseeby100
    @chaseeby100 8 หลายเดือนก่อน

    Thank you!

    • @bugbytes3923
      @bugbytes3923  8 หลายเดือนก่อน

      Thanks a lot for watching!

  • @danielcallaghan6892
    @danielcallaghan6892 2 ปีที่แล้ว +1

    aweome, very clear!

  • @MagnusAnand
    @MagnusAnand 10 หลายเดือนก่อน

    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.

  • @MagnusAnand
    @MagnusAnand ปีที่แล้ว

    It would be cool if you could make a video about using composition in Django 💪

  • @fernandtape9363
    @fernandtape9363 2 ปีที่แล้ว +1

    Hi Bugbytes, thanks for this new video. Can this model inheritance be used in product variation of an eccommerce? If yes, how?

    • @bugbytes3923
      @bugbytes3923  2 ปีที่แล้ว +3

      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!

  • @truthdawn7773
    @truthdawn7773 2 ปีที่แล้ว +2

    ❤️👌

  • @sarozpradhan64
    @sarozpradhan64 ปีที่แล้ว

    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.