#30243: Reduce structural dependency in contrib.admin 'has_file_field' checks
------------------------------------------------+--------------------------
Reporter: btknu | Owner: btknu
Type: Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
------------------------------------------------+--------------------------
This ticket is about a very small cleanup. It's possible that a Trac
ticket isn't necessary for this, I decided to make one to stay on the safe
side.
The PR https://github.com/django/django/pull/9298 for ticket
https://code.djangoproject.com/ticket/28585 adds code:
{{{
'has_file_field': context['adminform'].form.is_multipart() or
any(
admin_formset.formset.form().is_multipart()
for admin_formset in context['inline_admin_formsets']
),
}}}
This snippet invokes `is_multipart()` on formset's `form()` object.
But the formset (specifically: `BaseFormSet`) already provides an
`is_multipart()` method.
It feels cleaner to rely on a single place to calculate `is_multipart` for
a formset.
This way if `is_multipart` logic gets more complex, we only need to update
it in one place and there's less risk of bugs.
I suggest replacing:
{{{
admin_formset.formset.form().is_multipart()
}}}
with:
{{{
admin_formset.formset.is_multipart()
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30243>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/048.25993afa64f0737c9cc38ea4f12afcd1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.