Hi Malcolm

Thanks for looking in at this. There is some magic aura about this
group.
Both times I've posted to it, I've found other folks solutions that I
could
not find before I finally, in desperation, post ... and then magically
they
appear ... (In this case, I finally found the combination of search
terms
that popped the answer to the top ... and that only a few minutes
after I posted).

So, the solution was to loop over hidden fields per formset form
within
the template and then it worked fine.

Apologies that I'm not asking my questions in the way you'd like,
but believe me, I am cutting it down a lot ... and I appreciate that
it's still not obvious where the errors are (I would have found
them otherwise). In this case, I had cut it down to just field, and
it
exhibited the problem ... I shouldn't have included the extra line
which was just to show why I wanted to do it ...

It would seem that the advice to loop over hidden fields in the
template could be promoted to the documentation. It's not an
obvious thing to do ... especially since the hidden fields in
question seem to be per form management (and one
can't write out a management_form per form within a
formset and this seems to be fundamentally the same issue).

Cheers
Bryan


On 11 Aug, 02:35, Malcolm Tredinnick <malc...@pointy-stick.com> wrote:
> On Mon, 2009-08-10 at 08:59 -0700,bnlwrote:
> > 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