Django custom user model in admin, relation “auth_user” does not exist

前端 未结 5 1832
小鲜肉
小鲜肉 2020-12-13 15:46

I have a custom user model as below:

class User(AbstractUser):
    subscribe_newsletters = models.BooleanField(default=True)
    old_id = models.IntegerField         


        
5条回答
  •  孤城傲影
    2020-12-13 16:28

    I had to:

    1. delete the database
    2. create a new database
    3. delete all migrations from all models
    4. make migrations anew
    5. migrate

    It was double annoying because I had to do it on local and remote server. I tried just deleting migrations or deleting the database but then git would push/pull the old migrations and messed everything up.

    P.S. This bug initially arose because I ran the migrations before adding AUTH_USER_MODEL = 'customauth.MyUser' to the settings.py file, which is not version controlled.

提交回复
热议问题