diff --git a/django/forms/fields.py b/django/forms/fields.py index ecad857f72..0a0aa12f98 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -61,7 +61,7 @@ class Field(object): creation_counter = 0 def __init__(self, required=True, widget=None, label=None, initial=None, - help_text=None, error_messages=None, show_hidden_initial=False, + help_text='', error_messages=None, show_hidden_initial=False, validators=[], localize=False): # required -- Boolean that specifies whether the field is required. # True by default. @@ -82,14 +82,9 @@ class Field(object): # hidden widget with initial value after widget. # validators -- List of addtional validators to use # localize -- Boolean that specifies if the field should be localized. - if label is not None: - label = smart_text(label) self.required, self.label, self.initial = required, label, initial self.show_hidden_initial = show_hidden_initial - if help_text is None: - self.help_text = '' - else: - self.help_text = smart_text(help_text) + self.help_text = help_text widget = widget or self.widget if isinstance(widget, type): widget = widget() @@ -739,7 +734,7 @@ class ChoiceField(Field): } def __init__(self, choices=(), required=True, widget=None, label=None, - initial=None, help_text=None, *args, **kwargs): + initial=None, help_text='', *args, **kwargs): super(ChoiceField, self).__init__(required=required, widget=widget, label=label, initial=initial, help_text=help_text, *args, **kwargs) self.choices = choices @@ -999,7 +994,7 @@ class MultiValueField(Field): class FilePathField(ChoiceField): def __init__(self, path, match=None, recursive=False, allow_files=True, allow_folders=False, required=True, widget=None, label=None, - initial=None, help_text=None, *args, **kwargs): + initial=None, help_text='', *args, **kwargs): self.path, self.match, self.recursive = path, match, recursive self.allow_files, self.allow_folders = allow_files, allow_folders super(FilePathField, self).__init__(choices=(), required=required, diff --git a/django/forms/models.py b/django/forms/models.py index 39d753b1a6..5185e17c32 100644 --- a/django/forms/models.py +++ b/django/forms/models.py @@ -935,7 +935,7 @@ class ModelChoiceField(ChoiceField): def __init__(self, queryset, empty_label="---------", cache_choices=False, required=True, widget=None, label=None, initial=None, - help_text=None, to_field_name=None, *args, **kwargs): + help_text='', to_field_name=None, *args, **kwargs): if required and (initial is not None): self.empty_label = None else: @@ -1031,7 +1031,7 @@ class ModelMultipleChoiceField(ModelChoiceField): def __init__(self, queryset, cache_choices=False, required=True, widget=None, label=None, initial=None, - help_text=None, *args, **kwargs): + help_text='', *args, **kwargs): super(ModelMultipleChoiceField, self).__init__(queryset, None, cache_choices, required, widget, label, initial, help_text, *args, **kwargs) diff --git a/tests/forms_tests/tests/forms.py b/tests/forms_tests/tests/forms.py index ff4630b7d6..310525e0a5 100644 --- a/tests/forms_tests/tests/forms.py +++ b/tests/forms_tests/tests/forms.py @@ -952,12 +952,12 @@ class FormsTestCase(TestCase): class UserRegistration(Form): username = CharField(max_length=10, label='Your username') password1 = CharField(widget=PasswordInput) - password2 = CharField(widget=PasswordInput, label='Password (again)') + password2 = CharField(widget=PasswordInput, label='Contraseña (de nuevo)') p = UserRegistration(auto_id=False) self.assertHTMLEqual(p.as_ul(), """
""") - # A label can be a Unicode object or a bytestring with special characters. - class UserRegistration(Form): - username = CharField(max_length=10, label='ŠĐĆŽćžšđ') - password = CharField(widget=PasswordInput, label='\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111') - - p = UserRegistration(auto_id=False) - self.assertHTMLEqual(p.as_ul(), '
Username: e.g., user@example.com
-Password: Choose wisely.
""") +Password: Wählen Sie mit Bedacht.
""") self.assertHTMLEqual(p.as_table(), """