﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35304	IntegerField trailing decimal and zeros	Piotr Kotarba	nobody	"I have a little concern in regard of stripping trailing decimal and zeros.

IntegerField Uses NumberInput as widget, which allows to pass Numbers with trailing zeros. 
For example, below numbers are valid:
10
10.00
10,00

Shouldn't IntegerField accept only Integers? 

Below method uses _lazy_re_compile to get rid of them.

{{{
    def to_python(self, value):
        """"""
        Validate that int() can be called on the input. Return the result
        of int() or None for empty values.
        """"""
        value = super().to_python(value)
        if value in self.empty_values:
            return None
        if self.localize:
            value = formats.sanitize_separators(value)
        # Strip trailing decimal and zeros.
        try:
            value = int(self.re_decimal.sub('', str(value)))
        except (ValueError, TypeError):
            raise ValidationError(self.error_messages['invalid'], code='invalid')
        return value
}}}


I have found related issue:
https://code.djangoproject.com/ticket/24229

The reason of this functionality as I understand was:
""Django forms are useful for validating user input beyond just HTML forms.""
""One issue, MS Excel represents all numbers in cells as floats, even integers. So for this to work, a float with value 1.0 should be cleaned by forms.IntegerField as 1. ""

I am sceptic to this solution, and as Django main purpose is to be used on HTML, it shouldn't have such functionality in its core.
Also I think that this issue was created when there was no inputs, and HTML looked different as well. Lots have changed since then.

What do you think?
"	Uncategorized	closed	Forms	5.0	Normal	invalid			Unreviewed	0	0	0	0	0	0
