Skip to content Skip to sidebar Skip to footer

Typeerror At /userregis/ __init__() Got An Unexpected Keyword Argument 'username'

The question I meet is that, when I use UserReg.objects.create(), it will report things above. And I really had look up the solution for seaveral hours, but it doesn't work. So I

Solution 1:

Replace

clienter = UserReg.objects.create_user( user_name, password = pass_word,email = user_mail )

with

clienter = UserReg.objects.create_user( username=user_name, password = pass_word,email = user_mail )

Solution 2:

You can try this in another way.

user = UserReg()
user.username = user_name
user.email = user_mail
user.set_password(pass_word)
user.save()

and try by adding this in your user model

    class Meta(AbstractUser.Meta):
         swappable = 'AUTH_USER_MODEL'

Post a Comment for "Typeerror At /userregis/ __init__() Got An Unexpected Keyword Argument 'username'"