我有2个简单的模型; “JobInfo”模型和“联系”模型。
class JobInfo(models.Model):
client = models.CharField(max_length=50, choices=CLIENT_CHOICES)
job_number = models.CharField(max_length=30, unique=True, blank=True, null=True)
page_type = models.CharField(max_length=50, choices=PT_CHOICES)
contact = models.CharField(max_length=50, choices=CONTACT_CHOICES?)
def __unicode__ (self):
return self.job_number
class Admin:
pass
class Contact(models.Model):
name = models.CharField(max_length=64, unique=False, blank=True, null=True)
position = models.CharField(max_length=50, choices=CLIENT_CHOICES)
phone = models.CharField(max_length=15, unique=False, blank=True, null=True)
fax = models.CharField(max_length=15, unique=False, blank=True, null=True)
email = models.EmailField()
def __unicode__ (self):
return self.name
class Admin:
pass
我的“联系”对象(来自Contact Model)可以选择“JobInfo”模型中的联系人字段吗?我希望能够在JobInfo表单中选择联系人,并将这些联系人属性显示在同一模板中。
答案 0 :(得分:0)
class JobInfo(models.Model):
...
contact = Contact(models.Model)
答案 1 :(得分:0)