类Staff(AbstractBaseUser):
email = models.EmailField(verbose_name="email", max_length=60, unique=True)
username = models.CharField(max_length=60, unique=True)
date_joined = models.DateTimeField(verbose_name="Date Joined", auto_now_add=True)
last_login = models.DateTimeField(verbose_name="Last Login", auto_now_add=True)
is_admin = models.BooleanField(default=False)
is_active = models.BooleanField(default=True)
is_staff = models.BooleanField(default=False)
is_superuser = models.BooleanField(default=False)
first_name = models.CharField(max_length=60)
last_name = models.CharField(max_length=60)
position = models.CharField(max_length=45)
department_fk = models.ForeignKey(
Department, models.CASCADE, db_column='department_fk') <----- This is what im worried about
我不知道它是否会在Django中接受外键。
任何人都可以给我建议如何正确执行此操作吗?
它创建迁移并允许我迁移,但是当我创建超级用户时,会出现此错误
mysql.connection.query(self, query)
django.db.utils.OperationalError: (1054, "Unknown column 'app_staff.id' in 'field list'")
如果有人遇到相同的问题,请给我发消息或对此帖子发表评论,我会为我的问题提供答案