I was getting an IntegrityError
while working with the User
model in django.contrib.auth.models
, with a call for a check to see if the User
model’s username was unique. I solved this by using a call to User.objects.create_user()
instead of instantiating a new User()
and manually setting all necessary attributes.
As a side note, if you’re working with the django.contrib.auth.forms UserCreationForm
, be aware that there won’t be a password
field in the returned form. There are instead password1
and password2
fields.