D-oh! Look at this, a recent (?) dev version handles this for me: self.subforms.append( SimpleItemForm(item, prefix='line_%s' % n) )
This prefixes the IDs for each form field with line_N. (Oddly, it then uses a hyphen to separate my prefix. I had expected an underscore.) The names come out as line_1-FieldName. It's then child's play to tell which datum belong to which field. :) Happy, happy! On 07-Jun-10, at 6:10 PM, David Priest wrote: > > request.POST returns a QueryDict object for those fields that have > the same key. The key appears to be assigned by Django when it > magics the form and template into an http response. > > It seems difficult to get Django to deal with multiple lines on a > form, ie. as when creating almost any business form where there's a > single header (names, addresses) and many lines (SKUs, descriptions, > costs, quantities, etc). > > One of the easier ways of dealing with this is to simply use two > forms, one for the header and one for the line item, and then to > repeat the line item a number of times over. Unfortunately, Django > doesn't provide an easy way to differentiate between these lines; the > field ids will all be the same. Munging the field names doesn't > work; that just makes it impossible to refer to them on the template > (variable names aren't dynamic). > > So we seem to be stuck getting lists back. Question is, *is the > order of the list guaranteed*? Which is to say that will the first > items in SKU, Description, and Cost all refer to the same object; the > second items to the second object; and so on? > > And if not, how does one deal with this situation? > > The Admin interface does it. I haven't been able to figure out where > it does it, so I can steal its method... > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---