我读过类似的问题,但无法得出解决方案或结论。在同一应用程序中创建新模型类以及在新应用程序中创建新模型类时,出现此错误。错误
django.db.utils.IntegrityError: UNIQUE constraint failed: auth_permission.content_type_id, auth_permission.codename
我的模型。py
from django.db import models
from django.contrib.auth.models import User
CHOICES = (('Earned Leave','Earned Leave'),('Casual Leave','Casual Leave'),('Sick Leave','Sick Leave'),('Paid Leave','Paid Leave'))
STATUS_CHOICES = (('0', 'Rejected'),('1', 'Accepted'),)
MANAGER_CHOICES = (('0001_manager', '0001_manager'),('0002_manager', '0002_manager'))
class Leave(models.Model):
employee_ID = models.CharField(max_length = 20)
name = models.CharField(max_length = 50)
user = models.ForeignKey(User, on_delete = models.CASCADE, null =True)
def __str__(self):
return self.name
class B(models.Model):
state = models.CharField(max_length=50)
答案 0 :(得分:0)
删除所有先前的迁移,然后再次进行make-migrations。会的。