Hi,

PURPOSE: Mimic the admin "inline" functionality (with
ForeignKeyrelationships) in one of my own forms without using
Javascript (because I
don't know it)

My Solution: Inline Formset via inline_formset()

However,

   - inline_formset() does not accept initial as an argument
   - This is after the form has been submitted once and I want to create new
   forms in the formsets while still keeping the data already entered, waiting
   to be edited

I am using the following workaround in the mean time: (the entire view may
be found here: http://dpaste.com/hold/555463/)

        elif 'more_items' in request.POST:
            order = form.save(commit=False) # models.Order
            instances = formset.save(commit=False) # models.OrderItem(s)
            for instance in instances:
                initial_data.append({'item': instance.item,
                                     'quantity_requested':
instance.quantity_requested,
                                     }
                )
            formset = OrderFormset() #created via inline_formset()
            for subform, data in zip(formset.forms, initial_data):
                subform.initial = data
            # render_to_response....

The problem is, this limits me to a total number of forms as defined in the
extra field passed to inline_formset().

Any improvements or totally new solutions are welcome! My Python/Django
knowledge is beginner-intermediate (leaning towards beginner)

-- 
Yours,
Nikhil Somaru

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