> > This always creates a new partner! In fact, in the ModelForm > documentation is written that the save() method creates a new instance > unless an existing instance is passed to the ModelForm constructor. So > one has to differentiate if the POST comes from an initially empty > form or from a bound form! How can this be done? I believe that it > could be easily achieved if the primary-key were always included as a > hidden field. If it's empty, then 'create' otherwise 'get' & 'update'. > >> >> DELETE: >> #if you have a partner object named partner_instance >> partner_instance.delete() >> >> READ: >> What do you mean? >> Partner.objects.get(pk = 12) #or whatever
You are right, I made a mistake there. I typed it off of the top of my head, instead of copying and pasting from working code. All you have to do is what I did above in the create -- have an if statement. If the partner already exists, you have to get that object (using the Partner.objects.get(your_criteria_here) and pass it using the 'instance' keyword. Something like: #if it's an existing partner: partner_form = PartnerForm(instance = partner_instance) #else: partner_form = PartnerForm(request.POST) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

