Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #3337 -- Changed newforms Field subclasses to use super(). Than…

…ks for the patch, Dirk Datzert

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4366 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 5e8c1a6c47ac35d4704b48fad1d72443a0c8100c 1 parent 51a21bc
@adrianholovaty adrianholovaty authored
Showing with 19 additions and 19 deletions.
  1. +19 −19 django/newforms/fields.py
View
38 django/newforms/fields.py
@@ -86,11 +86,11 @@ def widget_attrs(self, widget):
class CharField(Field):
def __init__(self, max_length=None, min_length=None, required=True, widget=None, label=None, initial=None):
self.max_length, self.min_length = max_length, min_length
- Field.__init__(self, required, widget, label, initial)
+ super(CharField, self).__init__(required, widget, label, initial)
def clean(self, value):
"Validates max_length and min_length. Returns a Unicode object."
- Field.clean(self, value)
+ super(CharField, self).clean(value)
if value in EMPTY_VALUES:
value = u''
if not self.required:
@@ -109,7 +109,7 @@ def widget_attrs(self, widget):
class IntegerField(Field):
def __init__(self, max_value=None, min_value=None, required=True, widget=None, label=None, initial=None):
self.max_value, self.min_value = max_value, min_value
- Field.__init__(self, required, widget, label, initial)
+ super(IntegerField, self).__init__(required, widget, label, initial)
def clean(self, value):
"""
@@ -139,7 +139,7 @@ def clean(self, value):
class DateField(Field):
def __init__(self, input_formats=None, required=True, widget=None, label=None, initial=None):
- Field.__init__(self, required, widget, label, initial)
+ super(DateField, self).__init__(required, widget, label, initial)
self.input_formats = input_formats or DEFAULT_DATE_INPUT_FORMATS
def clean(self, value):
@@ -147,7 +147,7 @@ def clean(self, value):
Validates that the input can be converted to a date. Returns a Python
datetime.date object.
"""
- Field.clean(self, value)
+ super(DateField, self).clean(value)
if value in EMPTY_VALUES:
return None
if isinstance(value, datetime.datetime):
@@ -168,7 +168,7 @@ def clean(self, value):
class TimeField(Field):
def __init__(self, input_formats=None, required=True, widget=None, label=None, initial=None):
- Field.__init__(self, required, widget, label, initial)
+ super(TimeField, self).__init__(required, widget, label, initial)
self.input_formats = input_formats or DEFAULT_TIME_INPUT_FORMATS
def clean(self, value):
@@ -176,7 +176,7 @@ def clean(self, value):
Validates that the input can be converted to a time. Returns a Python
datetime.time object.
"""
- Field.clean(self, value)
+ super(TimeField, self).clean(value)
if value in EMPTY_VALUES:
return None
if isinstance(value, datetime.time):
@@ -202,7 +202,7 @@ def clean(self, value):
class DateTimeField(Field):
def __init__(self, input_formats=None, required=True, widget=None, label=None, initial=None):
- Field.__init__(self, required, widget, label, initial)
+ super(DateTimeField, self).__init__(required, widget, label, initial)
self.input_formats = input_formats or DEFAULT_DATETIME_INPUT_FORMATS
def clean(self, value):
@@ -210,7 +210,7 @@ def clean(self, value):
Validates that the input can be converted to a datetime. Returns a
Python datetime.datetime object.
"""
- Field.clean(self, value)
+ super(DateTimeField, self).clean(value)
if value in EMPTY_VALUES:
return None
if isinstance(value, datetime.datetime):
@@ -232,7 +232,7 @@ def __init__(self, regex, max_length=None, min_length=None, error_message=None,
error_message is an optional error message to use, if
'Enter a valid value' is too generic for you.
"""
- Field.__init__(self, required, widget, label, initial)
+ super(RegexField, self).__init__(required, widget, label, initial)
if isinstance(regex, basestring):
regex = re.compile(regex)
self.regex = regex
@@ -244,7 +244,7 @@ def clean(self, value):
Validates that the input matches the regular expression. Returns a
Unicode object.
"""
- Field.clean(self, value)
+ super(RegexField, self).clean(value)
if value in EMPTY_VALUES: value = u''
value = smart_unicode(value)
if not self.required and value == u'':
@@ -282,12 +282,12 @@ def __init__(self, max_length=None, min_length=None, required=True, widget=None,
class URLField(RegexField):
def __init__(self, max_length=None, min_length=None, required=True, verify_exists=False, widget=None, label=None,
initial=None, validator_user_agent=URL_VALIDATOR_USER_AGENT):
- RegexField.__init__(self, url_re, max_length, min_length, gettext(u'Enter a valid URL.'), required, widget, label, initial)
+ super(URLField, self).__init__(url_re, max_length, min_length, gettext(u'Enter a valid URL.'), required, widget, label, initial)
self.verify_exists = verify_exists
self.user_agent = validator_user_agent
def clean(self, value):
- value = RegexField.clean(self, value)
+ value = super(URLField, self).clean(value)
if not self.required and value == u'':
return value
if self.verify_exists:
@@ -314,21 +314,21 @@ class BooleanField(Field):
def clean(self, value):
"Returns a Python boolean object."
- Field.clean(self, value)
+ super(BooleanField, self).clean(value)
return bool(value)
class ChoiceField(Field):
def __init__(self, choices=(), required=True, widget=Select, label=None, initial=None):
if isinstance(widget, type):
widget = widget(choices=choices)
- Field.__init__(self, required, widget, label, initial)
+ super(ChoiceField, self).__init__(required, widget, label, initial)
self.choices = choices
def clean(self, value):
"""
Validates that the input is in self.choices.
"""
- value = Field.clean(self, value)
+ value = super(ChoiceField, self).clean(value)
if value in EMPTY_VALUES: value = u''
value = smart_unicode(value)
if not self.required and value == u'':
@@ -342,7 +342,7 @@ class MultipleChoiceField(ChoiceField):
hidden_widget = MultipleHiddenInput
def __init__(self, choices=(), required=True, widget=SelectMultiple, label=None, initial=None):
- ChoiceField.__init__(self, choices, required, widget, label, initial)
+ super(MultipleChoiceField, self).__init__(choices, required, widget, label, initial)
def clean(self, value):
"""
@@ -367,7 +367,7 @@ def clean(self, value):
class ComboField(Field):
def __init__(self, fields=(), required=True, widget=None, label=None, initial=None):
- Field.__init__(self, required, widget, label, initial)
+ super(ComboField, self).__init__(required, widget, label, initial)
# Set 'required' to False on the individual fields, because the
# required validation will be handled by ComboField, not by those
# individual fields.
@@ -380,7 +380,7 @@ def clean(self, value):
Validates the given value against all of self.fields, which is a
list of Field instances.
"""
- Field.clean(self, value)
+ super(ComboField, self).clean(value)
for field in self.fields:
value = field.clean(value)
return value
Please sign in to comment.
Something went wrong with that request. Please try again.