#28585: Set `has_file_field` context attribute for admin change forms conditionally on form `is_multipart` method -----------------------------------------+-------------------------- Reporter: Mark Rogaski | Owner: nobody Type: New feature | Status: assigned Component: contrib.admin | Version: 1.11 Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 0 | -----------------------------------------+-------------------------- In django.contrib.admin.options.ModelAdmin:
{{{ def render_change_form(self, request, context, add=False, change=False, form_url='', obj=None): ... context.update({ ... 'has_file_field': True, # FIXME - this should check if form or formsets have a FileField, ... }}} This attribute is used to determine whether a `multipart/form-data` is used for the form content type instead of `application/x-www-form- urlencoded`. I'd like to implement this behavior as it appears to have been intended (and I have a situation where multipart forms should only be used if necessary for file uploads). However, it's likely that some applications might be adversely impacted if the behavior changes. Perhaps adding an `AVOID_MULTIPART_ADMIN_FORMS` setting or an `avoid_multipart ModelAdmin` attribute that defaults to the current behavior is appropriate (better suggestions for the naming are welcome). In any case, I'd like to be able to have non-multipart forms returned when multipart isn't needed without having to subclass ModelAdmin. I am also happy to submit a PR for this based upon the preferred approach to backward compatibility. -- Ticket URL: <https://code.djangoproject.com/ticket/28585> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/051.f2aa7a1d586ae67459ea12adfe661b39%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.