The Django Docs uses this example to demonstrate multi-table inheritance:
from django.db import models
class Place(models.Model):
name = models.CharField(max_length=50)
address = models.CharField(max_length=80)
class Restaurant(Place):
serves_hot_dogs = models.BooleanField(default=False)
serves_pizza = models.BooleanField(default=False)
If I had initially built the Restaurant class like so:
class Restaurant(models.Model):
name = models.CharField(max_length=50)
address = models.CharField(max_length=80)
serves_hot_dogs = models.BooleanField(default=False)
serves_pizza = models.BooleanField(default=False)
and then after a bunch of Restaurant objects have already been created, I realize it would have been better to use MTI, is there a good way to create the parent Place class after the fact and migrate the data?
Office
model which also has a name and address and I want all addresses to be unique; so I want to add the Place and the Office class and migrate my existing Restaurant data to use the new data structure. – Dulaneyabstract
must be written all-lowercase. – Subtitle