On Tue, Mar 17, 2009 at 11:09 AM, Stefan Tunsch <stun...@gmail.com> wrote:

>
> Hi!
>
> I am having trouble getting a formset to work and handling the uploaded
> files.
>
> First of all, let me say that it's the first time I'm working with
> formsets.
> I've also never before tried to upload files.
> It is possible that I might be misunderstanding some basic stuff...
>
> My scenario is the following:
>
> I have a form with one FileField:
>
> class AttachmentForm(forms.Form):
>    myfile = forms.FileField(required=False)
>
> In my views.py file i do the following:
>
> from django.forms.formsets import formset_factory
> AttachmentFormSet = formset_factory(AttachmentForm, extra=3)
>
> if request.method == 'POST':
>    attachmentset = HoraAdjuntoFormSet(request.POST, request.FILES)
>    if attachmentset.is_valid:
>        #This is when things start to be awkward
>        print len(request.FILES) #returns zero
>        print len(attachmentset.cleaned_data) #returns 3, which is correct
>        for cd in attachmentset.cleaned_data:
>            print cd #Returns 3 empty dictionary {}
>
> Any help will be appreciated.
>
>
> Regards, Stefan
>
>
> >
>
You should be calling `is_valid` as it's a function, not a property:
attachmentset.is_valid()

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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