class Customer(models.Model):
"""客户信息表"""
name = models.CharField(max_length=32, blank=True, null=True)
qq = models.CharField(max_length=64, unique=True)
qq_name = models.CharField(max_length=64, blank=True, null=True)
phone = models.CharField(max_length=64, blank=True, null=True)
source_choice = ((0, '转介绍'),
(1, 'QQ群'),
(2, '官网'),
(3, '百度推广'),
(4, '51CTO'),
(5, '知乎'),
(6, '市场推广'),
)
source = models.SmallIntegerField(choices=source_choice)
referral_from = models.CharField(verbose_name="转介绍人QQ", max_length=64, blank=True, null=True)
consult_course = models.ForeignKey("Course", verbose_name="资讯课程")
content = models.TextField(verbose_name="咨询详情")
tags = models.ManyToManyField("Tag", blank=True, null=True)
consultant = models.ForeignKey(verbose_name="UserProfile")
memo = models.TextField(blank=True, null=True)
date = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.qq
class UserProfile(models.Model):
"""用户账户表"""
user = models.OneToOneField(User)
name = models.CharField(max_length=32)
roles = models.ManyToManyField("Role", bank=True, null=True)
def __str__(self):
return self.name
当我在终端中运行此代码(python manage.py makemigration crms)时, Traceback(最近一次调用最后一次): 在客户的文件“D:\ python \ CRM项目实战\ CRM \ crm \ crms \ models.py”,第26行 consultant = models.ForeignKey(verbose_name =“UserProfile”) TypeError: init ()缺少1个必需的位置参数:'to'“”“”
答案 0 :(得分:0)
consultant = models.ForeignKey(verbose_name="UserProfile")
您忘了定义FK目标表。
答案 1 :(得分:0)
您没有指定外键引用的表,
consultant = models.ForeignKey(Table_name, verbose_name="UserProfile")