Ticket #20298: fields.patch

File fields.patch, 844 bytes (added by krishna@…, 11 years ago)

Strips the value before checking for emptiness in case of FloatField and IntegerField

  • django/forms/fields.py

    diff --git a/django/forms/fields.py b/django/forms/fields.py
    index 146a10d..eab33e9 100644
    a b class IntegerField(Field):  
    240240        Validates that int() can be called on the input. Returns the result
    241241        of int(). Returns None for empty values.
    242242        """
     243        value = value.strip()
    243244        value = super(IntegerField, self).to_python(value)
    244245        if value in self.empty_values:
    245246            return None
    class FloatField(IntegerField):  
    271272        Validates that float() can be called on the input. Returns the result
    272273        of float(). Returns None for empty values.
    273274        """
     275        value = value.strip()
    274276        value = super(IntegerField, self).to_python(value)
    275277        if value in self.empty_values:
    276278            return None
Back to Top