Re: Can't get form to update, rather than insert

2009-11-24 Thread Daniel Roseman
On Nov 24, 4:42 am, Nick Arnett  wrote:
> I have a form that I've tried creating a couple of ways, including as a
> ModelForm, which doesn't seem to want to perform an UPDATE operation.  I'm
> hoping for some help here... If I create it as a ModelForm, it doesn't
> validate, I'm guessing because the form doesn't include the foreign keys in
> the model (I haven't tried passing them in the form - that shouldn't be
> necessary - but I probably will, next).  If I create a form from the POST
> data, it complains that required fields are missing.
>
> My reading of the docs is that if I supply the primary key and the row
> exists, an UPDATE should happen, which won't care if required fields are
> present or not (since I don't want to change those values).  But that's not
> happening - no matter what I do, it seems to be generating an error that
> indicates it is trying to create a new row with a duplicate ID.
>
> Anybody have a working example of a form that updates, rather than inserts?
> Oh, and forcing an update in the save method doesn't solve the problem.
>
> I have no problem performing updates outside of the context of forms - I
> just can't figure out how to get it to work with forms.
>
> Thanks in advance,
>
> Nick

Examples are in the modelforms documentation. Maybe you could post
some code so we can see what you're doing wrong?
--
DR.

--

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.




Can't get form to update, rather than insert

2009-11-23 Thread Nick Arnett
I have a form that I've tried creating a couple of ways, including as a
ModelForm, which doesn't seem to want to perform an UPDATE operation.  I'm
hoping for some help here... If I create it as a ModelForm, it doesn't
validate, I'm guessing because the form doesn't include the foreign keys in
the model (I haven't tried passing them in the form - that shouldn't be
necessary - but I probably will, next).  If I create a form from the POST
data, it complains that required fields are missing.

My reading of the docs is that if I supply the primary key and the row
exists, an UPDATE should happen, which won't care if required fields are
present or not (since I don't want to change those values).  But that's not
happening - no matter what I do, it seems to be generating an error that
indicates it is trying to create a new row with a duplicate ID.

Anybody have a working example of a form that updates, rather than inserts?
Oh, and forcing an update in the save method doesn't solve the problem.

I have no problem performing updates outside of the context of forms - I
just can't figure out how to get it to work with forms.

Thanks in advance,

Nick

--

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.