django required file field validation
<p>Working with django form in which i have two file uploads fields one for artist image and another for event poster, both of these fields are required. </p>

<pre><code>class CreateEventStepFirstForm(forms.Form):
    event_title = forms.CharField(required = True, max_length=20, widget=forms.TextInput(attrs={
        'class' : 'custome-input promote-input', 
        'autocomplete' : 'off',
        'data-empty-message':'This field is required' 
    }))
    ticket_title = forms.CharField(required = True, max_length=225, widget=forms.TextInput(attrs={
        'class' : 'custome-input promote-input', 
        'autocomplete' : 'off',
        'data-empty-message':'This field is required' 
    }))
    artist_image = forms.FileField(required = True, widget=forms.FileInput(attrs={
        'class' : 'upload-img',
        'data-empty-message':'Please upload artist image, this field is required'
    }))
    event_poster = forms.FileField(required = True, widget=forms.FileInput(attrs={
        'class' : 'upload-img',
        'data-empty-message':'Please upload artist image, this field is required'
    }))
</code></pre>

<p>Problem is that all fields are validated properly except these two file fields, when i select images for both artist_image and event_poster it don't validate the fields and give "This field is required" error even i select both images.</p>

<p><img src="https://i.stack.imgur.com/mh43W.png" /></p>

<p>You need to add <code>request.FILES</code> as follows:</p>

<pre><code>form = CreateEventStepFirstForm(request.POST, request.FILES)
</code></pre>

python django