MultiFileWidget

This is a multi file upload widget. That does not require adding multiple file input fields. It requires jQuery.MultiUpload (http://www.fyneworks.com/jquery/multiple-file-upload/)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

fromdjango.newforms.widgetsimportInputclassMultiFileInput(Input):input_type='file'needs_multipart_form=Truedefrender(self,name,value,attrs=None):ifattrsisNone:attrs={}ifattrs.has_key('class'):attrs['class']+=' multi'else:attrs['class']='multi'name+='[]'returnsuper(MultiFileInput,self).render(name,None,attrs=attrs)defvalue_from_datadict(self,data,files,name):"File widgets take data from FILES, not POST"returnfiles.get(name,None)