#30520: ModelForm with field without label crashes when used in
InlineModelAdmin.
---------------------------------+------------------------------------
Reporter: George Tantiras | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by felixxm):
* component: Uncategorized => contrib.admin
* version: 2.2 => master
* easy: 0 => 1
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted
Comment:
Thanks for the report. I think that passing an empty form to the
`label_for_field()` should fix this issue, e.g.
{{{
diff --git a/django/contrib/admin/helpers.py
b/django/contrib/admin/helpers.py
index 83719f4346..aa07581391 100644
--- a/django/contrib/admin/helpers.py
+++ b/django/contrib/admin/helpers.py
@@ -289,7 +289,7 @@ class InlineAdminFormSet:
form_field = empty_form.fields[field_name]
label = form_field.label
if label is None:
- label = label_for_field(field_name, self.opts.model,
self.opts)
+ label = label_for_field(field_name, self.opts.model,
self.opts, form=empty_form)
yield {
'name': field_name,
'label': label,
}}}
Reproduced at 67b6cb7723b2765cb776bd59d5603e3e63eefc2e.
--
Ticket URL: <https://code.djangoproject.com/ticket/30520#comment:1>
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/066.d1aa3c24a21fff2ca684b3fafbd632a1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.