I am developing a custom usermodel for my application in django, by using AbstractUser.
But I am getting a UNIQUE constraint failed error while using add user
from django admin.
I have also tried to add unique = False
in the EmailField
class User(AbstractUser):
id = models.BigAutoField(primary_key=True)
rollno = models.CharField(null=True,unique=True,max_length=15)
email = models.EmailField(blank=True,null=True,unique=False)
Error :
....
return Database.Cursor.execute(self, query, params)
django.db.utils.IntegrityError: UNIQUE constraint failed: Accounts_user.email
[28/Jun/2022 05:54:58] "POST /admin/Accounts/user/add/ HTTP/1.1" 500 233697
The add form does not have a email field, submits a blank email.
(PS : I can add user by signup form of my application, change user
of django admin is also working.)\
CodePudding user response:
in the above code, there should not be any problem with migrations. i think your old migrations are creating problem here. check your old migrations and delete them.