On Mon, 2009-08-10 at 08:59 -0700, bnl wrote:
> hi folks
> 
> I have a formset, which I want to display using a customised template
> for the forms.
> 
> This works:
> 
> {{formset.mangement_form}}
> {% for form in formset.forms %}
>   {{form}}
> {% endfor %}
> 
> The following displays ok, let's me edit one form, but then I can't
> update it or add another, failling with a muMultiValueDictKeyError
> at ....
> "Key 'form-0-id' not found in <QueryDict: .... (this with django 1.1,
> 1.0 blew up with a keyerror).
> 
> {{formset.management_forms}}
> {% for form in formset.forms %}
> {{form.title.errors}}{{form.title}}
> etc looping over the fields in a nice way ...
> {% endfor %}
> 
> Looking at the posted form in an editor, I see the following (with
> django 1.0) in the form that works:
> <input type="hidden" name="form-0-id" value="1" id="id_form-0-id" />
> and
> <input type="hidden" name="form-0-id" id="id_form-0-id" />
> in the one that doesn't.

Since the one that doesn't work doesn't have any value associated with
it, it won't be submitted as a form element (which is why you are not
seeing it as a key in the form data). In other words, it's being
rendered incorrectly. So it's working fine, given what is being
rendered.

> 
> Any idea what I'm doing wrong? need to do?

The details are hidden in the line you have written as "looping over the
fields in a nice way".

Construct a small self-contained example of a form and formset class and
show exactly how you are attempting to display the form fields and we
might have some chance of spotting the problem. Work hard on removing
every detail that isn't necessary -- removing form elements and formset
details as much as possible until the error disappears. Ideally, you'll
end up with a form with only one field and it will become apparent what
the problem is.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
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