Ok, so i want to update info about user with custom form that looks like this.
<form action="" >
<!--csrftoken-->
<input type="text" placeholder="Your new name" name="name">
<input type="text" placeholder="Your new email" name="email">
<input type="text" placeholder="Your new number" name="number">
<button type="submit" class="raise">Submit</button>
</form>
How to update user with the data that was filled. Let's say user fills in the number and the email field and the rest was left blank, email and number are changed but the name was left untouched. I was thinking about form prepopulating, but this calls for another database request and i want to avoid that.
def updateCustomer(request):
current = request.user
if request.method == 'POST':
newphone = request.POST['newPhone']
newemail = request.POST['email']
newname = request.POST['name']
addingToBase = Customer.objects.get(user=current)
xD = addingToBase(email=newemail,name=newname,phone=newphone)
xD.save()
return redirect('home')