带PostgreSQL的Django 1.11。表“app_employee”的多个主键是不允许的。
我去迁移我的网站和models.py
引发错误,我不能有多个主键。我看不到我在哪里(或者我不了解如何)。
class Employee(models.Model):
Aegis_ID = models.UUIDField(primary_key=True, null=False, default=uuid.uuid4, editable=False, serialize=True)
Employee_Number = models.ForeignKey('self', on_delete=models.CASCADE, related_name='Company_Employee_Number',
null=True, blank=True, max_length=6, help_text="Employee ID")
Employee_FName = models.CharField(null=True, blank=True, max_length=25, help_text="First Name")
Employee_LName = models.CharField(null=True, blank=True, max_length=25, help_text="Last Name")
Employee_Email = models.EmailField(max_length=80, blank=True, help_text="GPM Email address")
Employee_Position = models.ForeignKey('self', on_delete=models.CASCADE, null=True, blank=True,
related_name='Department_Employee_Position', max_length=3,
choices=EMPLOYEE_POSITION, help_text="Select position of this Employee.")
Hire_Date = models.DateField(null=True, blank=True, help_text="Enter the employee hire date.")
Employee_Division = models.CharField(max_length=2, null=True, blank=True, choices=DIVISION_CHOICES,
help_text="Assign the Audit Division for this employee.")
Employee_Region = models.CharField(max_length=3, null=True, blank=True, choices=REGION_CHOICES,
help_text="Assign the Audit Region for this employee.")
Employee_District = models.CharField(max_length=3, null=True, blank=True, choices=DISTRICT_CHOICES,
help_text="Assign the Audit District for this Employee.")
阅读这个确切主题Django的页面,它的上市为1.7解决的问题,不得不做Django是如何分类的类的表,按字母顺序。
我也试过python manage.py flush
随后makemigrations
之前migrate
那么,哪些字段是Django的/的Postgres试图进行“ID”和“主”,因为我只是不理解,在这里.. 。
根据关于自动主键Django文档,还有看不见的是id = models.AutoField(primary_key=True)
但我也明白,如果您分配primary_key=True
到现场,这并不适用