Editing forms in django

37 views
Skip to first unread message

amanjot kaur

unread,
Oct 18, 2013, 3:39:42 AM10/18/13
to django...@googlegroups.com
What should I need to do in django, if I want to edit the information
filled in django, like we edit our profile in facebook after filling
once?
--
Amanjot Kaur

Blog: kauramanjot35.wordpress.com

Sandeep kaur

unread,
Oct 18, 2013, 2:40:21 PM10/18/13
to django-users
On Fri, Oct 18, 2013 at 1:09 PM, amanjot kaur <kauram...@gmail.com> wrote:
> What should I need to do in django, if I want to edit the information
> filled in django, like we edit our profile in facebook after filling
> once?

That means editing the already saved data?

Assuming you are using a ModelForm, use the instance keyword argument,
and pass the model you are updating.

So, if you have MyModel and MyModelForm, then your code might look like:

my_record = MyModel.objects.get(id=XXX)
form = MyModelForm(instance=my_record)

And then, when the user sends back data by POST:

form = MyModelForm(request.POST, instance=my_record)

Documentation is here:
http://docs.djangoproject.com/en/1.3/topics/forms/modelforms/


--
Sandeep Kaur
E-Mail: mkaur...@gmail.com
Blog: sandymadaan.wordpress.com
Reply all
Reply to author
Forward
0 new messages