如何解决Django:'str'对象在create_user
这是我的注册码
def registration_with_js_form(request):
if request.method=='POST':
first_name=request.POST.get('first_name')
last_name=request.POST.get('last_name')
mobile_number=request.POST.get('mobile_number')
email=request.POST.get('email')
password=request.POST.get('password')
confirm_password=request.POST.get('confirm_password')
checkbox=request.POST.get('checkbox')
if checkbox==False:
"""Redirect with error message"""
return redirect('home')
if(password!=confirm_password):
"""Redirect with error message"""
return redirect('home')
code =''.join(random.choices(string.ascii_uppercase,k=3))
random_str=str(random.randint(10,99))+str(code)
username_=first_name+"@"+random_str
print(username_)
curr_user=Account.objects.create_user(email=email,username=username_,password=password)
curr_user.phone_number=mobile_number
curr_user.first_name=first_name
curr_user.last_name=last_name
curr_user.save()
"""Redirect with success message"""
return redirect('home')
return render(request,'main/index.html')
这是我的抽象用户模型
并且它显示这样的错误
并且所有字段都是包含我在该表单中填写的适当数据的字段 如果我打印所有这些
print([first_name,last_name,mobile_number,email,password,confirm_password,checkbox])
OutPut ['Samir','Patil','1234567890','m@gmail.com','123','on']
请帮忙。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。