mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	Fixed #28332 -- Fixed diamond inheritence example in docs.
This commit is contained in:
		
				
					committed by
					
						 Tim Graham
						Tim Graham
					
				
			
			
				
	
			
			
			
						parent
						
							60443e84b3
						
					
				
				
					commit
					473ab4610e
				
			| @@ -1346,15 +1346,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): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user