diff options
| author | Jeremy Satterfield <jsatt22@gmail.com> | 2017-08-17 13:06:29 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-09-02 14:33:19 -0400 |
| commit | e921e983876b62f5b8f405e0b8afcdcc1f53d8bb (patch) | |
| tree | efd9a8e1c7d4dcc40f04bed3cd04a8c847e1ce71 | |
| parent | 07f73daf6ba2994e572776edbbf3266f2f09d7a5 (diff) | |
[1.11.x] Fixed #28332 -- Fixed diamond inheritence example in docs.
Backport of 473ab4610ef90be05f09127aa37cd20bcda5875e from master
| -rw-r--r-- | docs/topics/db/models.txt | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/docs/topics/db/models.txt b/docs/topics/db/models.txt index 6ee07f712a..f4034f6ba7 100644 --- a/docs/topics/db/models.txt +++ b/docs/topics/db/models.txt @@ -1359,15 +1359,20 @@ use an explicit :class:`~django.db.models.AutoField` in the base models:: class BookReview(Book, Article): pass -Or use a common ancestor to hold the :class:`~django.db.models.AutoField`:: +Or use a common ancestor to hold the :class:`~django.db.models.AutoField`. This +requires using an explicit :class:`~django.db.models.OneToOneField` from each +parent model to the common ancestor to avoid a clash between the fields that +are automatically generated and inherited by the child:: class Piece(models.Model): pass class Article(Piece): + article_piece = models.OneToOneField(Piece, on_delete=models.CASCADE, parent_link=True) ... class Book(Piece): + book_piece = models.OneToOneField(Piece, on_delete=models.CASCADE, parent_link=True) ... class BookReview(Book, Article): |
