TypeError:save()缺少1个必需的位置参数:“ self”

kerberos

这是意见

class RegisterView(View):
def get(self,request):
    register_form = RegisterForm()
    return render(request,'register.html',{'register_form':register_form})
def post(self,request):
    register_form = RegisterForm(request.POST)
    if register_form.is_valid():
        user_name = request.POST.get("email", '')
        pass_word = request.POST.get("password", '')
        user_profile = UserProfile
        user_profile.username = user_name
        user_profile.email = user_name
        user_profile.password = make_password(pass_word)
        user_profile.save()   #error
        send_register_email(user_name,"register")

我想将user_profile保存到mysql,但是user_profile.save()出错,TypeError:save()缺少1个必需的位置参数:'self',我应该如何解决?

尴尬的

您尚未实例化的对象UserProfile,而是要分配UserProfileuser_profile

user_profile = UserProfile

应该

user_profile = UserProfile()

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

/ save() 处的 TypeError 缺少 1 个必需的位置参数:'self'

/ api / products / 1 save()处的TypeError缺少1个必需的位置参数:“ self”

save() 缺少 1 个必需的位置参数“self”

TypeError:缺少1个必需的位置参数:'self'

TypeError:endturn()缺少1个必需的位置参数:“ self”

TypeError:kollision()缺少1个必需的位置参数:“ self”

TypeError:close()缺少1个必需的位置参数:“ self”

TypeError:str()缺少1个必需的位置参数:“ self”

获取 TypeError fit() 缺少 1 个必需的位置参数:'self'

缺少1个必需的位置参数:'self'

method1()缺少1个必需的位置参数:“ self”

类型错误:save() 缺少 1 个必需的位置参数:'self':DjangoRestframework

此类型错误的问题:save() 缺少 1 个必需的位置参数:pycharm django 中的“self”

/listing 处的类型错误:save() 缺少 1 个必需的位置参数:“self”

如何解决此“ TypeError:read()缺少1个必需的位置参数:'self'”

调用python函数时发生错误,TypeError:returnbook()缺少1个必需的位置参数:“ self”

selenium webdriver TypeError: to_capabilities() 缺少 1 个必需的位置参数:'self'

Keras模型保存错误:TypeError:get_config()缺少1个必需的位置参数:'self'

TypeError:get_params()缺少1个必需的位置参数:“ self”

Python-TypeError:listen()缺少1个必需的位置参数:“ self”

TypeError:player_attack()缺少1个必需的位置参数:“ self”

TypeError:grid_configure()缺少1个必需的位置参数:“ self”

如何修复 TypeError: getText() 缺少 1 个必需的位置参数:python 中的“self”?

__init__() 缺少 1 个必需的位置参数:'self'

python:缺少1个必需的位置参数:'self'

fit()缺少1个必需的位置参数:“ self”

类型错误:gassens() 缺少 1 个必需的位置参数:'self'

使用self时缺少1个必需的位置参数

main()缺少1个必需的位置参数:“ self”