create_user() takes from 2 to 4 positional arguments but 6 were given

后端 未结 1 888
半阙折子戏
半阙折子戏 2021-01-29 08:52

after i fill the registration form and click submit this error pops up \"create_user() takes from 2 to 4 positional arguments but 6 were given\" and also it doesn\'t use the val

相关标签:
1条回答
  • 2021-01-29 09:07

    create_user expects only the username as a positional parameter. All the other data should be passed as keyword arguments.

    user = User.objects.create_user(
        self.cleaned_data['username'],
        first_name=self.cleaned_data['first_name'],
        last_name=self.cleaned_data['last_name'],
        email=self.cleaned_data['email'],
        password=self.cleaned_data['password1']
    )
    
    0 讨论(0)
提交回复
热议问题