diff options
| author | Ramiro Morales <cramm0@gmail.com> | 2013-04-15 10:54:37 -0300 |
|---|---|---|
| committer | Ramiro Morales <cramm0@gmail.com> | 2013-05-20 16:29:51 -0300 |
| commit | 4ba1c2e785feecfa7a47aa5336a2b595f086a765 (patch) | |
| tree | 9b5c4ced8c5af019f389349bea1e7a94e221856e /django | |
| parent | 2fd61285d109a04bf22d1822e834cbb7bcf4239f (diff) | |
Fixed #9321 -- Deprecated hard-coding of help text in model ManyToManyField fields.
This is backward incompatible for custom form field/widgets that rely
on the hard-coded 'Hold down "Control", or "Command" on a Mac, to select
more than one.' sentence.
Application that use standard model form fields and widgets aren't
affected but need to start handling these help texts by themselves
before Django 1.8.
For more details, see the related release notes and deprecation timeline
sections added with this commit.
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/fields/related.py | 5 | ||||
| -rw-r--r-- | django/forms/models.py | 5 |
2 files changed, 5 insertions, 5 deletions
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index 256c3e0f61..fd0b24433f 100644 --- a/django/db/models/fields/related.py +++ b/django/db/models/fields/related.py @@ -11,7 +11,7 @@ from django.db.models.deletion import CASCADE from django.utils.encoding import smart_text from django.utils import six from django.utils.deprecation import RenameMethodsBase -from django.utils.translation import ugettext_lazy as _, string_concat +from django.utils.translation import ugettext_lazy as _ from django.utils.functional import curry, cached_property from django.core import exceptions from django import forms @@ -1348,9 +1348,6 @@ class ManyToManyField(RelatedField): super(ManyToManyField, self).__init__(**kwargs) - msg = _('Hold down "Control", or "Command" on a Mac, to select more than one.') - self.help_text = string_concat(self.help_text, ' ', msg) - def _get_path_info(self, direct=False): """ Called by both direct an indirect m2m traversal. diff --git a/django/forms/models.py b/django/forms/models.py index 93c8b89efe..68c1341cf7 100644 --- a/django/forms/models.py +++ b/django/forms/models.py @@ -18,7 +18,7 @@ from django.utils.encoding import smart_text, force_text from django.utils.datastructures import SortedDict from django.utils import six from django.utils.text import get_text_list, capfirst -from django.utils.translation import ugettext_lazy as _, ugettext +from django.utils.translation import ugettext_lazy as _, ugettext, string_concat __all__ = ( @@ -1104,6 +1104,9 @@ class ModelMultipleChoiceField(ModelChoiceField): super(ModelMultipleChoiceField, self).__init__(queryset, None, cache_choices, required, widget, label, initial, help_text, *args, **kwargs) + if isinstance(self.widget, SelectMultiple): + msg = _('Hold down "Control", or "Command" on a Mac, to select more than one.') + self.help_text = string_concat(self.help_text, ' ', msg) if self.help_text else msg def clean(self, value): if self.required and not value: |
