Tuesday, December 4, 2012

Re: Inline formset with different default values for each "extra" row

Because Lee Hinde's thread is broken, I'm going to take a punt at what the question is :)

in a formset (inline, model, or just a plain one), the "initial" parameter to the instantiation of the form takes an list of dictionaries. Each element in the list is the initial data for _that_ row... so if you want 5 different part numbers, for example, do this.


formset = MyFormSet ( ..other params..,  initial=[{'partno':10},{'partno':11},{'partno':12},{'partno':13},{'partno':14}] )

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/2gJzJTG-U_MJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate