diff --git a/django/contrib/admin/helpers.py b/django/contrib/admin/helpers.py
index ea6e0012dd..88895ce144 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 |
264 | 271 | 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 | | } |
| 272 | label, help_text = get_field_label_and_help_text(form, field_name, self.opts) |
| 273 | widget = {'is_hidden': False} |
| 274 | required = False |
271 | 275 | else: |
272 | | form_field = self.formset.empty_form.fields[field_name] |
| 276 | form_field = form.fields[field_name] |
273 | 277 | label = form_field.label |
274 | 278 | if label is None: |
275 | 279 | 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 | | } |
| 280 | help_text = form_field.help_text |
| 281 | widget = form_field.widget |
| 282 | required = form_field.required |
| 283 | yield { |
| 284 | 'label': label, |
| 285 | 'widget': widget, |
| 286 | 'required': required, |
| 287 | 'help_text': help_text, |
| 288 | } |
282 | 289 | |
283 | 290 | def inline_formset_data(self): |
284 | 291 | verbose_name = self.opts.verbose_name |