What is the difference between a Multi-table inherited model and a simple
One-to-one relationship between the same two models?
What is the differences between these implementations? What does Django
differently (beside inheriting Meta ordering and get_latest_by attribute)
?
1.
# models.py
from django.db import models
class Place(models.Model):
name = models.CharField(max_length=50)
class Restaurant(models.Model):
place = models.OneToOneField(Place)
serves_pizza = models.BooleanField()
2.
class Place(models.Model):
name = models.CharField(max_length=50)
class Restaurant(Place):
serves_pizza = models.BooleanField()
3.
class Place(models.Model):
name = models.CharField(max_length=50)
class Restaurant(Place):
place = models.OneToOneField(Place, parent_link=True)
serves_pizza = models.BooleanField()
No comments:
Post a Comment