thank you very much for your Feedback!

Am Freitag, 22. September 2017 18:24:23 UTC+2 schrieb mike:
>
> I do it this way too and agree that it feels dirty. Curious to hear what 
> others have to say about this!
>
> On Fri, Sep 22, 2017 at 9:18 AM, guettli <guet...@gmail.com <javascript:>> 
> wrote:
>
>> I am not happy with this snippet from the django docs:
>>
>>
>> from django.views.generic.edit import FormViewfrom .forms import 
>> FileFieldForm
>> class FileFieldView(FormView):
>>     form_class = FileFieldForm
>>     template_name = 'upload.html'  # Replace with your template.
>>     success_url = '...'  # Replace with your URL or reverse().
>>
>>     def post(self, request, *args, **kwargs):
>>         form_class = self.get_form_class()
>>         form = self.get_form(form_class)
>>         files = request.FILES.getlist('file_field')
>>         if form.is_valid():
>>             for f in files:
>>                 ...  # Do something with each file.
>>             return self.form_valid(form)
>>         else:
>>             return self.form_invalid(form)
>>
>> Source: 
>> https://docs.djangoproject.com/en/1.11/topics/http/file-uploads/#uploading-multiple-files
>>
>> My problem: The form instance can't validate the files.
>>
>> AFAIK in the method form.clean() I don't have a list of files.
>>
>> I can work around this, but it breaks the nice separation of concerns which
>> I usually get with the nice django form library :-) 
>>
>> Imagine my app receives three files. Is there a way to validate these files 
>> inside form.clean()?
>>
>> Regards,
>>   Thomas Güttler
>>
>> -- 
>> 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...@googlegroups.com <javascript:>.
>> To post to this group, send email to django...@googlegroups.com 
>> <javascript:>.
>> 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/07e6b78b-6af2-466b-acb3-0a285c3e201b%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/07e6b78b-6af2-466b-acb3-0a285c3e201b%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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+unsubscr...@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/f46df930-1621-45a2-a876-1da8a2c0e6e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to