this is views
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")
I want to save user_profile to mysql,But user_profile.save() has an error, TypeError: save() missing 1 required positional argument: 'self',How should I solve it?
user_profile = UserProfile()instead ofuser_profile = UserProfileand check its output. - aquaman.cleaned_datato retrieve the email and password instead of getting them fromrequest.POST. Or use aModelForminstead... - bruno desthuilliers