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