I have a table which holds simple data like addresses. Created a form which 
displays the records in the form and allows the user to select a record 
"address" to edit. 

I want this edit function to be generic so it will work on any table 
without me having to define fields etc... and using  ModelForm I 
accomplished by goal. 

Django creates a form and using instance='myrecord' it even populated the 
fields in the form with the record I want to edit. I can edit my fields  
and now it is time to save the changes back to the database.

I found a .save() method for 
# Create a form to edit an existing Article, but use
# POST data to populate the form.
>>> a = Article.objects.get(pk=1)
>>> f = ArticleForm(request.POST, instance=a) >>> f.save()

My question is this:
The .save method discuss in the Django Documentation above is a method of 
ModelForm but I have rendered my form and when I hit the SUBMIT button the 
edited fields are returned in a WSGI type object which does not have a save 
method.

I can use the POST data and pass the PK and so on, and update the record 
manually with some code. BUT WHAT is the use of a .SAVE method on a 
ModelForm. In order to edit the form I need to RENDER it right?

Is there a way to return the ModelForm object with the edited fields and 
then save back to the database?

Thanks 

Moose

 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6ccb9692-5f95-4f8a-86b1-18259b00c0dan%40googlegroups.com.

Reply via email to