[Django]-UNIQUE constraint failed: auth_user.username

2👍

If you use the default authenticate function not providing a password should always (?) fail, which means that

has_account = authenticate(first_name = first_name, last_name = last_name)

always will be None.

But the main problem is that you do not set a username for the new User, only first_name and last_name. This will work once, but after one User with an empty username was created the next attempt will fail, as Users need an unique username.
So: Add a username!

Besides that, I think that

user = facebook_user.save()

does not assign the User to “user” but the Form.
You should use facebook_user.instance.

Leave a comment