On Thu, Jan 7, 2010 at 7:14 PM, Alastair Campbell <ala...@gmail.com> wrote:

>
> I've put the model form definition and the view up here:
> http://dpaste.com/142308/
>
> Any idea what I'm doing wrong? Perhaps something to do with loading
> the form with data in the first place?
>
>
You want to pass the instance parameter when you create the form from POST
data, same as you do when you create the form initially for display.  That
is where the form's initial data comes from.  When you create a form with
just the POST dictionary and no instance parameter, every supplied field in
the data dictionary appears to have changed since there is no initial data.

Using the instance parameter is the POST leg also allows you to simply
save() the form to get the changes to the instance saved.  There is then no
need to individually copy each of the fields from the form's cleaned_data
dict to the model instance.  See:

http://docs.djangoproject.com/en/1.1/topics/forms/modelforms/#the-save-method

Karen
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Reply via email to