Validate that float() can be called on the input. Return the result of float() or None for empty values.
(self, value)
| 367 | } |
| 368 | |
| 369 | def to_python(self, value): |
| 370 | """ |
| 371 | Validate that float() can be called on the input. Return the result |
| 372 | of float() or None for empty values. |
| 373 | """ |
| 374 | value = super(IntegerField, self).to_python(value) |
| 375 | if value in self.empty_values: |
| 376 | return None |
| 377 | if self.localize: |
| 378 | value = formats.sanitize_separators(value) |
| 379 | try: |
| 380 | value = float(value) |
| 381 | except (ValueError, TypeError): |
| 382 | raise ValidationError(self.error_messages["invalid"], code="invalid") |
| 383 | return value |
| 384 | |
| 385 | def validate(self, value): |
| 386 | super().validate(value) |
nothing calls this directly
no test coverage detected