4

I have forms.Form in django. In this form there is a forms.FileField. This field is rendered in html as

<input id="id_upload-loaded_file" name="upload-loaded_file" type="file">

I need to add accepted files only with ".zip" extension so that form will be rendered as

<input id="id_upload-loaded_file" name="upload-loaded_file" type="file" accept=".zip">

How can I add accepted file extension attribute in django?

1 Answer 1

5

This is how I did it:

zip_file = forms.FileField(label='Select zip file', widget=forms.FileInput(attrs={'accept': '.zip'}))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.