Answer the question
In order to leave comments, you need to log in
How to edit model data through a form?
There is an extended User model, there is a form that is associated with this model. How to implement a function for editing data?
def show_user_form(request):
if request.method == 'POST':
form = RedactInfoUserForm(request.POST, request.FILES)
if form.is_valid():
form.save()
redirect('profile')
else:
form = RedactInfoUserForm()
return render(request, 'shop/user_profile.html', {'form':form})
Answer the question
In order to leave comments, you need to log in
Add a parameter to the form (in both calls):
form = RedactInfoUserForm(instance=some_user) # some_user - КОНКРЕТНЫЙ юзер из бд, выбранный по id/логину и т.д.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question