﻿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
35342	models.fields.IntegerField.to_python() is converting float type numbers, making .clean_fields( ) less reliable	thiper01@…	nobody	"During the full_clean( ) routine, when an IntegerField is being cleaned and the code calls the field's to_python( ) method, if the value of the field is a float, it will just be converted to an integer using {{{int(value)}}}. As it is characteristic of python's native int( ) function, it converts any float to int regardless of decimal places and approximations necessary, allowing for examples like this to happen:

{{{
exModel = ModelWithIntegerField(value=1.2)
>>   exModel.value     #1.2
exModel.clean_fields() #no validation error raised
>>   exModel.value     #1
}}}

I don't know if this behaviour is because of ticket #24229, but I believe there are better ways than just allowing any number through IntegerField verification as long as it's a number, regardless of how it affects the output.

My suggestions to improve this are:
1# Check first if it's a float type then verify if the numbers after the decimal point are 0 {{{if value%1 == 0}}}, if they are, no problem converting, if not raise a TypeError as it would distort the original value without warning.
"	Bug	closed	Database layer (models, ORM)	5.0	Normal	wontfix			Unreviewed	1	0	0	0	1	0
