Code

Opened 4 years ago

Closed 4 years ago

#12359 closed (duplicate)

db/models/fields/related.py hardcodes m2m help_text for select widget

Reported by: olau Owned by: nobody
Component: Uncategorized Version: 1.1
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

There's a bit of code in the many to many field definition that appends some help for the standard usability-troubled HTML select widget to the help_text:

  msg = ugettext_lazy('Hold down "Control", or "Command" on a Mac, to select more than one.')
  self.help_text = string_concat(self.help_text, ' ', msg)

This means that if you define a custom help_text, you have to take care to someone de-append the help_text when overwriting the widget for a form, e.g. when using the built-in CheckboxSelectMultiple widget instead of a plain select box.

Practical issues aside, it's also probably not a good idea to hardcode the help_text for a particular presentational widget in the db layer, had to grep the whole codebase to find it. :)

I suggest the text be moved to the SelectMultiple widget in the forms code.

Attachments (1)

help_text_r12827.diff (2.2 KB) - added by trey@… 4 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 4 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 4 years ago by trey@…

  • Has patch set

This assumption should probably not be made at all. I think the django admin (which is why this was added I'm sure) should store this in a constant somewhere and append it when it needs it like any app that's created by a django user would need to do.

Changed 4 years ago by trey@…

comment:3 Changed 4 years ago by crucialfelix@…

+1 : its not the domain of the database field

but trey says above that it should be the admin that does it. IMO it should be the widget that adds advice as to how to operate its own widget. it should never be assumed that the admin is present

comment:4 Changed 4 years ago by kmtracey

  • Resolution set to duplicate
  • Status changed from new to closed

This is already reported in #9321.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.