2๐
โ
Try like this in view, you need to pass the instance to the form inorder to update the same,
def profile_form_update(request):
instance = get_object_or_404(UserProfile, user=request.user)
if request.method == 'POST':
form = UserProfileForm(request.POST, request.FILES, instance=instance)
if form.is_valid():
instance = form.save(commit=False)
instance.user = request.user
instance.save()
else:
form = UserProfileForm(instance=instance)
context = {
"form":form,
"instance": instance,}
return render(request, "profile_form.html", context)
๐คzaidfazil
Source:stackexchange.com