Re: FormSet issue. Pre-populating from queryset

2008-12-11 Thread maeck
Malcolm, Thanks for the comment. I truly understand where this is coming from. This issue is completely my issue of taking things for granted. I have been coding around in Django for a while now (hooked on in the 0.95 days), and have been coding most of the form stuff (including inlines) all by h

Re: FormSet issue. Pre-populating from queryset

2008-12-11 Thread Malcolm Tredinnick
On Thu, 2008-12-11 at 20:55 -0800, maeck wrote: [...] > Now I can pass the fieldnames as values('parent') for now, It would be > easier if initial did not care if the _id is provided or not. > Or am I missing something else? What you're missing, or rather, assuming, is that querysets are ideal o

Re: FormSet issue. Pre-populating from queryset

2008-12-11 Thread Brian Rosner
On Thu, Dec 11, 2008 at 9:55 PM, maeck wrote: > Now I can pass the fieldnames as values('parent') for now, It would be > easier if initial did not care if the _id is provided or not. > Or am I missing something else? You shouldn't be using a regular formset. Django provides model formsets that k

Re: FormSet issue. Pre-populating from queryset

2008-12-11 Thread maeck
Thanks Malcolm, Just figured out the values transformation on querysets myself. Nevertheless, in my experience there seems to be an issue with foreignkeys when using queryset values in combination with formsets. Values returns keys like 'parent_id', however formsets expect the fieldname as 'paren

Re: FormSet issue. Pre-populating from queryset

2008-12-11 Thread Malcolm Tredinnick
On Thu, 2008-12-11 at 20:19 -0800, maeck wrote: > The example below is a snippet from a view where I use a form to show > 'Parent' and a formset to show its 'Children'. > If I get the children as a queryset and pass it on to the formsets > initial property, it errors out with: 'Parent' object is

FormSet issue. Pre-populating from queryset

2008-12-11 Thread maeck
The example below is a snippet from a view where I use a form to show 'Parent' and a formset to show its 'Children'. If I get the children as a queryset and pass it on to the formsets initial property, it errors out with: 'Parent' object is not iterable InlineFormSet = formset_factory(InlineFor