[Answer]-Django 1.7 – update a user record using a form

1👍

I suggest using UpdateView, one of Django’s class-based-views for generic editing:

class django.views.generic.edit.UpdateView

A view that displays a
form for editing an existing object, redisplaying the form with
validation errors (if there are any) and saving changes to the object.
This uses a form automatically generated from the object’s model class
(unless a form class is manually specified).

0👍

I managed to get the answer, i imported the form to

import the user that i want to edit

u = User.objects.get(username = user_name)

creating the form with values from existing in database and updating with values from POST

user_form = UserEditForm(request.POST,instance=u)

save the form, since it already has existing record it will update

user_form.save()

Leave a comment