I use a very similar design, except instead of instanceform = myform(instance=instance)
I use instanceform = form_for_Instance(instance) I'm not sure what the difference is, they should both return a valid Form that creates the necessary information, but I had issues like yourself for that too. HTH John On Apr 5, 10:58 am, "tyman26" <[EMAIL PROTECTED]> wrote: > >def add_edit_model(request, id=None): > > if id is not None: > > instance = MyModel.objects.get(id=id) > > InstanceForm = MyForm(instance=instance) > > else: > > InstanceForm = MyForm() > > if request.POST: > > form = InstanceForm(request.POST) > > if form.is_valid(): > > form.save() > > return HttpResponseRedirect('/whatever/url/') > > return render_to_response('template.html', {'form': InstanceForm}) > > I looked at this previous posting that showed the proper way to > construct add/edit newForms. I got most of it working, but I am > having trouble saving the edit form. > > The line of code "form = InstanceForm(request.POST)" doesn't make > any sense. The InstanceForm was already created so how can you pass > POST information to it again? When I use this method I keep adding > new items when I really only want to update a current item. Is there > some other way to pass the POST information to an instance form which > is already created? --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---