All, I have an issue with using InlineFormSets. Save of a new model goes without any issue. However, I have a problem with saving an existing model. When I save I get a KeyError without much info. Other than it happened in "/usr/lib/python2.5/site-packages/django/ forms/models.py in save_existing_objects".
I noticed an older ticket that talked about the form.id missing on the template. If I am correct managementform takes care of that. I'd appreciate some pointers on this issue. Maeck ### View code class ClassPaymentProductForm(ModelForm): class Meta: model = ClassPaymentProduct class ClassPaymentForm(ModelForm): class Meta: model = ClassPayment def edit_classpayment(request, classpayment_id=None): # View parameters Form = ClassPaymentForm InlineForm = ClassPaymentProductForm Model = ClassPayment InlineModel = ClassPaymentProduct template = 'test.html' data_id = classpayment_id if data_id == None: data = Model() else: data = Model.objects.get(id = data_id) InlineFormSet = inlineformset_factory(Model, InlineModel, can_delete=True) if request.method == "POST": mainform = Form(request.POST, instance=data) formset = InlineFormSet(request.POST, request.FILES, instance=data) if mainform.is_valid() and formset.is_valid(): mainform.save(request) formset.save() if '_save' in request.POST: return HttpResponseRedirect('/test/') if '_addanother' in request.POST: return HttpResponseRedirect('../add/') else: mainform = Form(instance=data) formset = InlineFormSet(instance=data) return render_to_response(template, { 'mainform' : mainform, 'formset' : formset, }) ### Template {% for f in formset.management_form %} {{ f }} {% endfor %} <table> <tr> {% for field in formset.forms.0 %} {% if not field.is_hidden %} <th>{{ field.label }}</th> {% endif %} {% endfor %} </tr> {% for f in formset.forms %} <tr> {% for field in f %} {% if not field.is_hidden %} <td valign="bottom">{{ field }}</ {% else %} {{ field.errors }} {{ field }} {% endif %} {% endfor %} </tr> {% endfor %} </table> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---