diff --git a/django/contrib/admin/helpers.py b/django/contrib/admin/helpers.py
index ea6e0012dd..0616f54d67 100644
a
|
b
|
from django.utils.translation import gettext, gettext_lazy as _
|
17 | 17 | ACTION_CHECKBOX_NAME = '_selected_action' |
18 | 18 | |
19 | 19 | |
| 20 | def get_field_label_and_help_text(form, field_name, model_admin): |
| 21 | if form._meta.labels and field_name in form._meta.labels: |
| 22 | label = form._meta.labels[field_name] |
| 23 | else: |
| 24 | label = label_for_field(field_name, form._meta.model, model_admin) |
| 25 | |
| 26 | if form._meta.help_texts and field_name in form._meta.help_texts: |
| 27 | help_text = form._meta.help_texts[field_name] |
| 28 | else: |
| 29 | help_text = help_text_for_field(field_name, form._meta.model) |
| 30 | |
| 31 | return (label, help_text) |
| 32 | |
| 33 | |
20 | 34 | class ActionForm(forms.Form): |
21 | 35 | action = forms.ChoiceField(label=_('Action:')) |
22 | 36 | select_across = forms.BooleanField( |
… |
… |
class AdminReadonlyField:
|
164 | 178 | else: |
165 | 179 | class_name = field |
166 | 180 | |
167 | | if form._meta.labels and class_name in form._meta.labels: |
168 | | label = form._meta.labels[class_name] |
169 | | else: |
170 | | label = label_for_field(field, form._meta.model, model_admin) |
171 | | |
172 | | if form._meta.help_texts and class_name in form._meta.help_texts: |
173 | | help_text = form._meta.help_texts[class_name] |
174 | | else: |
175 | | help_text = help_text_for_field(class_name, form._meta.model) |
| 181 | label, help_text = get_field_label_and_help_text(form, class_name, model_admin) |
176 | 182 | |
177 | 183 | self.field = { |
178 | 184 | 'name': class_name, |
… |
… |
class InlineAdminFormSet:
|
261 | 267 | for i, field_name in enumerate(flatten_fieldsets(self.fieldsets)): |
262 | 268 | if fk and fk.name == field_name: |
263 | 269 | continue |
| 270 | form = self.formset.empty_form |
| 271 | label, help_text = get_field_label_and_help_text(form, field_name, self.opts) |
264 | 272 | if field_name in self.readonly_fields: |
265 | | yield { |
266 | | 'label': label_for_field(field_name, self.opts.model, self.opts), |
267 | | 'widget': {'is_hidden': False}, |
268 | | 'required': False, |
269 | | 'help_text': help_text_for_field(field_name, self.opts.model), |
270 | | } |
| 273 | widget = {'is_hidden': False} |
| 274 | required = False |
271 | 275 | else: |
272 | | form_field = self.formset.empty_form.fields[field_name] |
273 | | label = form_field.label |
274 | | if label is None: |
275 | | label = label_for_field(field_name, self.opts.model, self.opts) |
276 | | yield { |
277 | | 'label': label, |
278 | | 'widget': form_field.widget, |
279 | | 'required': form_field.required, |
280 | | 'help_text': form_field.help_text, |
281 | | } |
| 276 | form_field = form.fields[field_name] |
| 277 | widget = form_field.widget |
| 278 | required = form_field.required |
| 279 | yield { |
| 280 | 'label': label, |
| 281 | 'widget': widget, |
| 282 | 'required': required, |
| 283 | 'help_text': help_text, |
| 284 | } |
282 | 285 | |
283 | 286 | def inline_formset_data(self): |
284 | 287 | verbose_name = self.opts.verbose_name |