Wednesday, August 24, 2016

how to access uploaded file list in django forms.py

Hello friends
how can i 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 to add request object to my form , but i get error when using this code :

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


this is the error:

Exception Value:    'NoneType' object has no attribute 'FILES'

i want it for form validation
any help is really appreciated

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACq8ZqDOvLNYSDqNLski_dMUfLYQD%3Dp7qjkE%2BHb94FmUZfX-DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment