1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Removed forced typecasting of help_text/label Field arguments

In any case, setting those variables to non-ascii utf-8 bytestrings
is now considered a programming error.
This commit is contained in:
Claude Paroz
2013-03-25 21:25:53 +01:00
parent d9b12ecbe6
commit 066bf42675
3 changed files with 13 additions and 33 deletions

View File

@@ -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,

View File

@@ -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)