Opened 21 months ago

Closed 21 months ago

Last modified 21 months ago

#20805 closed Bug (fixed)

form.label_suffix colon on admin checkboxes

Reported by: CollinAnderson Owned by: timo
Component: contrib.admin Version: 1.6-beta-1
Severity: Release blocker Keywords:
Cc: CollinAnderson Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

django1.5: http://snag.gy/JyMxI.jpg
django1.6b1: http://snag.gy/ilUNM.jpg

This is regression was introduced by #18134 584bd14dcfdee9585fec7794d53ce120ea73d0bc.

Here is the admin's algorithm for deciding when to add the colon:
https://github.com/django/django/blob/master/django/contrib/admin/helpers.py#L126
After the admin sets up the label it wants, it calls field.label_tag which then adds the colon back.

Attachments (2)

20805.diff (3.5 KB) - added by timo 21 months ago.
20805.2.diff (6.8 KB) - added by timo 21 months ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 21 months ago by timo

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to timo
  • Patch needs improvement unset
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

Changed 21 months ago by timo

comment:2 Changed 21 months ago by timo

  • Has patch set
  • Needs documentation set

Adding a proposal to add an include_label_suffix kwarg to label_tag. Will update the docs if this looks reasonable.

Changed 21 months ago by timo

comment:3 Changed 21 months ago by timo

  • Needs documentation unset

Added a more general solution that allows overriding label_suffix at the field level.

comment:4 Changed 21 months ago by claudep

The patch is rather good, but I'm afraid it doesn't cover the use case when you call label_tag in a template to render a checkbox field:

{{ form.cb_field }} {{ form.cb_field.label_tag }}

No better solution to propose yet...

comment:5 Changed 21 months ago by CollinAnderson

...another case where calling methods with arguments would be quite nice...

comment:6 Changed 21 months ago by timo

We could recommend writing a custom filter for that case.

comment:7 Changed 21 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In 8676318d2dae9a570d2314e4e6da8c00aaf2e2a0:

Fixed #20805 -- Removed an extra colon beside checkboxes in the admin.

Thanks CollinAnderson for the report.

comment:8 Changed 21 months ago by Tim Graham <timograham@…>

In dbbd2b1272e5a3ce7ab4b39b9a74f4ea725b104f:

[1.6.x] Fixed #20805 -- Removed an extra colon beside checkboxes in the admin.

Thanks CollinAnderson for the report.

Backport of 8676318d2d from master

Note: See TracTickets for help on using tickets.
Back to Top