Opened 7 years ago
Closed 7 years ago
#28744 closed New feature (invalid)
enctype on <input> if FileField
Reported by: | Thomas Güttler | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I think it would be feasible to add the attribute enctype
to html input elements for FileFields.
Related docs: https://developer.mozilla.org/de/docs/Web/HTML/Element/Input#attr-formenctype
My use case: to be able to stop this useless dancing in admin:
grep -rsi 'has_file_field' . ./contrib/admin/options.py: 'has_file_field': True, # FIXME - this should check if form or formsets have a FileField, ./contrib/admin/templates/admin/change_form.html:<form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.model_name }}_form" novalidate>{% csrf_token %}{% block form_top %}{% endblock %}
Change History (7)
comment:1 by , 7 years ago
Component: | Uncategorized → Forms |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → New feature |
Version: | 1.11 → master |
comment:3 by , 7 years ago
I didn't test, but I don't see anything to suggest that enctype
works on <input type="file" ... />
. From the page linked in the ticket description: "If the input element is a submit button or image, this attribute specifies the type of content that is used to submit the form to the server."
comment:4 by , 7 years ago
Wrong hope? Thomas?
We could still fix the FIXME of contrib/admin/options.py
, but that would have less appeal, of course.
comment:6 by , 7 years ago
Just for the records, we use the enctype=“multipart/form-data” now unconditionally (meaning always, for all forms)
Before, I asked here:
https://stackoverflow.com/questions/46952608/why-not-use-enctype-multipart-form-data-always
We use this since some days in production and have seen no drawback up to now.
This means: one of several solutions would be to remove the "FIXME" comment in the django source :-)
comment:7 by , 7 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
0cf00769ad11fa5ff0dff585d7f491a80f3e45ef is committed to address the FIXME. I don't think there's anything further to do for this ticket.
Indeed!