开发者

What's the difference between OneToOne and Subclassing a model in Django

开发者 https://www.devze.com 2022-12-18 02:27 出处:网络
For example: class Subdomain(Site): #fields 开发者_如何转开发here and class Subdomain(models.Model):

For example:

class Subdomain(Site):
    #fields 开发者_如何转开发here

and

class Subdomain(models.Model):
    site = models.OneToOne(Site)
    #fields here


Models with a OneToOne have an independent PK; submodels always use the PK of their supermodel.

0

精彩评论

暂无评论...
验证码 换一张
取 消