IntegerField (and subclasses), FloatField lack to_python method
|Reported by:||Owned by:||Adrian Holovaty|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
IntegerField (in django.db.models.fields) and FloatField subclass Field but do not define a to_python method. They inherit Field's simple 'return value' to_value implementation.
This can be a problem when using Django's XML serializer and deserializer together. Since the deserializer passes in a string representation of the value to to_python, a string representation of the value is written to the object. This can make string formatting (%d, %f) and presumably other code unhappy. I suspect that this may not cause a problem in all cases. If an error is not triggered, it may be possible for the values to be saved to the database without incident, thereby allowing future retrievals to have the appropriate types.
AutoField provides an implementation of to_python which seems appropriate to copy-and-paste into place for IntegerField. The positive integer variants may benefit from bounds checking. FloatField would need logic along similar lines