Original: http://www.twiola.com/en/questions/90/django-filefield-accept-image-and-video my django form have the input file type
class MediaForm(forms.Form): title = forms.CharField(max_lenght=256) media = forms.FileField()
the field for upload only images and video. But in browse i can select any file, example *.rar, *.xls and others files..
I find resolved input type file accept images, but how i can add the attribute accept="image/,video/" in django template??
my template
<form> {% csrf_token %} {{ form.title }} {{ form.media }} <input type="submit"> </form>
###Answered
media = forms.FileField(widget=forms.FileInput(attrs={'accept':'image/*,video/*'}))