[Django]-Django multiple inheritance E005

2👍

I just found out that I can actually name the link to the parent:

class Piece(models.Model):
    pass

class Article(Piece):
    article_to_piece = models.OneToOneField(Piece, parent_link=True)

class Book(Piece):
    book_to_piece = models.OneToOneField(Piece, parent_link=True)

class BookReview(Book, Article):
    pass

I’m still curious for other solutions though!

Leave a comment