Model in the abstract class table inheritance

# Main table 
class Base (models.Model):
create_time = models.DateTimeField (auto_now_add = True) # Create a time
update_time = models.DateTimeField (auto_now = True) # Updated
class Meta:
abstract = True # must write


class Stu(Base,models.Model):
name = models.CharField(max_length=32)
img = models.CharField(max_length=255)
duo = models.ManyToManyField(to='Kc',related_name='sss')#
class Meta:
db_table='stu'

Guess you like

Origin www.cnblogs.com/pp8080/p/11828644.html