0

how can i in Django access uploaded file list (multi file upload) in forms.py.

In a view i access file list like this :

request.FILES.getlist('files')

but in forms.py i get this error:

Exception Value:    'UploadForm' object has no attribute 'request'

i tried solution in this address but i get error when using this code :

def clean_files(self):
    data = self.request.FILES

error:

Exception Value:    

'NoneType' object has no attribute 'FILES'
Community
  • 1
  • 1
ali
  • 139
  • 8
  • The request object is not available in the context of the form by default. http://stackoverflow.com/questions/1057252/how-do-i-access-the-request-object-or-any-other-variable-in-a-forms-clean-met – karthikr Aug 24 '16 at 17:53
  • as i said above i did that but i get this error :` Exception Value: 'NoneType' object has no attribute 'FILES'` – ali Aug 24 '16 at 18:01
  • You first need to understand why that is happening. Then everything will make sense. `self.request` would be None, and you are trying to access `FILES` from there. Did you try and understand the answer provided in that link ? – karthikr Aug 24 '16 at 18:13

0 Answers0