The following snippet is returning an empty dictionary for the 2nd form:

 

> dct = {'form-0-attachment': u'',
>  'form-0-id': u'1',
>  'form-0-name': u'1',
>  'form-1-attachment': u'',
>  'form-1-id': u'2',
>  'form-1-name': u'2',
>  'form-INITIAL_FORMS': u'1',
>  'form-MAX_NUM_FORMS': u'1000',
>  'form-TOTAL_FORMS': 2}
> PictureFormSet = formset_factory(PictureForm)
> picture_formset = PictureFormSet(dct, None,
>                                  initial = [ model_to_dict(a) for a in 
> Picture.objects.filter(pk__in = [1,2])])
> for form in picture_formset.forms:
>     if form.is_valid():
>         print form.cleaned_data
>         print '-------------------'
> Output:
> {'id': 1, 'name': u'1', 'attachment': None}
> -------------------
> {}
> -------------------


How does initial work with data= in a formset?  Without the initial, there 
will be cleaned data for the 2nd form.

I'm trying to use self.changed_data in my form to determine whether which 
value has changed.




-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to