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?
you have not instantiated an object of UserProfile
, instead you are assigning UserProfile
to user_profile
user_profile = UserProfile
should be
user_profile = UserProfile()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With