Django не может изменить имя пользователя в пользовательской модели пользователя ⇐ Python
-
Anonymous
Django не может изменить имя пользователя в пользовательской модели пользователя
I have the following User model in Django's models.py:
class User(AbstractBaseUser): username = models.CharField(max_length=30, unique=True, primary_key=True) full_name = models.CharField(max_length=65, null=True, blank=True) email = models.EmailField( max_length=255, unique=True, validators=[EmailValidator()] ) When trying to update a username via shell python manage.py shell:
userobj = User.objects.get(username="username1") userobj.username = user.lower() userobj.save() It seems that it is trying to create a new user, for which the UNIQUE constraint of the e-mail is violated:
django.db.utils.IntegrityError: UNIQUE constraint failed: data_app_user.email Any solutions? Thank you!
Источник: https://stackoverflow.com/questions/780 ... user-model
I have the following User model in Django's models.py:
class User(AbstractBaseUser): username = models.CharField(max_length=30, unique=True, primary_key=True) full_name = models.CharField(max_length=65, null=True, blank=True) email = models.EmailField( max_length=255, unique=True, validators=[EmailValidator()] ) When trying to update a username via shell python manage.py shell:
userobj = User.objects.get(username="username1") userobj.username = user.lower() userobj.save() It seems that it is trying to create a new user, for which the UNIQUE constraint of the e-mail is violated:
django.db.utils.IntegrityError: UNIQUE constraint failed: data_app_user.email Any solutions? Thank you!
Источник: https://stackoverflow.com/questions/780 ... user-model