[Answer]-Django keyerror from built in form

1👍

You’re getting the error because create_user expects a parameter called password and NOT password1 that is used in UserCreationForm.

Notice the signature for create_user:

create_user(self, username, email=None, password=None, **extra_fields)

You can try calling the method like this:

cd = form.cleaned_data
User.objects.create_user(
    username=cd.get('username'),
    password=cd.get('password1'),
)

Leave a comment