例如:
class Subdomain(Site):
#fields here
和
class Subdomain(models.Model):
site = models.OneToOne(Site)
#fields here
最佳答案
带有OneToOne
的模型有一个独立的PK;子模特总是使用他们超模的 PK。
关于python - OneToOne 和 Django 中的模型子类化有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2149567/