#29184: TabularInline Read-only Fields Ignore ModelForm._meta Label and Help 
Text
Overrides
-------------------------------------+-------------------------------------
               Reporter:  David      |          Owner:  nobody
  Sanders                            |
                   Type:  Bug        |         Status:  new
              Component:             |        Version:  2.0
  contrib.admin                      |       Keywords:  readonly,
               Severity:  Normal     |  help_texts, labels
           Triage Stage:             |      Has patch:  1
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Providing a `ModelForm` for `admin.TabularInline` will have any
 `Meta.labels` or `Meta.help_texts` overrides for read-only fields ignored.
 This behavior is inconsistent with `ModelAdmin` and `admin.StackedInline`,
 which *do* respect those overrides.

 The difference in behavior comes down to the template rendering: with
 `TabularInline` the field names are rendered separately from the values,
 and so the label and help text are accessed differently. The
 
[https://github.com/django/django/blob/a38ae914d89809aed6d79337b74a8b31b6d3849a/django/contrib/admin/helpers.py#L264
 code which provides them] never looks at `ModelForm._meta`, but
 
[https://github.com/django/django/blob/a38ae914d89809aed6d79337b74a8b31b6d3849a/django/contrib/admin/helpers.py#L167
 code further up in the same file] does.

 I'm attaching a crude patch against master which factors out the existing
 logic and reuses it in both spots I linked. Discovered this issue while
 trying to meet a deadline for a project so I don't have time to do a
 proper PR or even run the tests. The patch works for my manual testing,
 but your mileage may vary. It at least illustrates where the issue is and
 a possible fix. **Note:** The patch does not keep the behavior in
 `AdminReadonlyField` where it flips between using `class_name` and
 `field`. No explanation is given in the code for why it alternates, and it
 seems illogical to me, but maybe someone knows better. The patch simply
 uses `class_name`.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29184>
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/053.641df05c861d5de71982e9f0a276b96f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to