KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have this use case scenario: there are places which are either playgrounds, restaurants, theatres, pubs. the same place can have playgrounds, restaurants, theatres etc. there are couple of ways of implementing it: use foreign keys class Place(models.Model): name = models.CharField(max_length=50) class PlayGrounds(models.Model) field1 = models.CharField(max_length=50) place = models.ForeignKey(Place) multitable inheritance class Place(models.Model): name = models.CharField(max_length=50) address = models.CharField(max_length=80) class Restaurant(Place): serves_hot_dogs = models.BooleanField() serves_pizza = models.BooleanField() use abstract class class Place(models.Model): name = models.CharField(max_length=50) class PlayGrounds(Place) field1 = models.CharField(max_length=50) place = models.ForeignKey(Place) class Meta: abstract = True use proxy models class Place(models.Model): name = models.CharField(max_length=50) class PlayGrounds(Place) field1 = models.CharField(max_length=50) place = models.ForeignKey(Place) class Meta: proxy = True What are the pros and cons of using each approach?
Tags (comma-separated)
Save Edits
Cancel