I am using graphene-django library and I have a User model that is inherited from AbstractUser. The username attribute is unique and it's ok for me. But The problem is that when I try to add a user with duplicated username id of user table in database increases. What's your idea?
It's my UserModel :
class User(AbstractUser):
email = models.EmailField(unique=True)
...
and its my mutate function:
def mutate(self, info, user_name, email, password, is_creator):
if validateEmail(email=email):
new_user = User.objects.create(username=user_name, email=email, password=password,
is_creator=is_creator, created_at=datetime.datetime.now(),
updated_at=datetime.datetime.now())
new_user.save()
ok = True
logger.info(LogMessages.new_user_added.format(user_name, email))
return UserCreator(user=new_user, ok=ok)
else:
error_message = LogMessages.input_email_is_invalid
ok = False
logger.info(LogMessages.input_email_is_invalid)
return UserCreator(ok=ok, error_message=error_message)