>From the djangoproject website:

http://docs.djangoproject.com/en/dev/topics/forms/modelforms/

<snip>
If you specify fields or exclude when creating a form with ModelForm,
then the fields that are not in the resulting form will not be set by
the form's save() method. Django will prevent any attempt to save an
incomplete model, so if the model does not allow the missing fields to
be empty, and does not provide a default value for the missing fields,
any attempt to save() a ModelForm with missing fields will fail. To
avoid this failure, you must instantiate your model with initial
values for the missing, but required fields:

    author = Author(title='Mr')
    form = PartialAuthorForm(request.POST, instance=author)
    form.save()

Alternatively, you can use save(commit=False) and manually set any
extra required fields:

    form = PartialAuthorForm(request.POST)
    author = form.save(commit=False)
    author.title = 'Mr'
    author.save()
</snip>

I hope that helps!

Paul






On Jul 28, 4:58 pm, Streamweaver <streamwea...@gmail.com> wrote:
> To be clear.  Essentially I just want to merge the object instance and
> POST data with the POST data overwriting the instance where it's
> supplied.  Right now if I don't supply a field in my POST data it just
> submits null values.
>
> Thanks again and sorry for any repetition or frustration.
>
> On Jul 28, 5:25 pm, Streamweaver <streamwea...@gmail.com> wrote:
>
> > I have been struggling with this for a few weeks without resolution
> > and hope someone can help me.
>
> > I have a model that I edit via a form but the field returned for
> > editing vary depending on the user permissions and group.
>
> > When I bind a form to POST data some fields may or may not be included
> > in that post.  All I really want to do is take the model I'm editing,
> > change anything submitted by the POST data and leave the rest as is
> > but I don't seem to be able to find a way to do this without having to
> > explicitly declare each field.  Is there a way around this or
> > something I'm missing.
>
> > Thanks in advance for any help.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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