这里我有包含联系人字段的卖家模式。我创建了一个新的模型名作为联系人,其中包含字段“联系人编号和地址”。
我可以简单地给出一个外键,将卖家模型的联系人字段转换为联系人模型。
但在这里,我想使用联系人模型作为卖家模型联系人字段的新数据类型。
class Contact(models.Model):
contact_number = PhoneNumberField(blank=False, null=False)
address = models.TextField(blank=False, null=False)
def __str__(self):
return "%s" % self.name
class Seller(models.Model):
company_name = models.CharField(max_length=300, blank=False, null=False)
company_profile = models.TextField(blank=False, null=False)
contact = Contact() #Here I want use Contact model as data type for the contact field
def __str__(self):
return "%s" % self.company_name
这有可能吗?
如果是的话,有人能指导我吗?我是新来的姜哥人,我只有姜哥的基本知识。
这里我使用PostgreSQL作为数据库。