      default_error_messages = {
          'invalid': _('A valid number is required.'),
          'max_value': _('Ensure this value is less than or equal to {max_value}.'),
          'min_value': _('Ensure this value is greater than or equal to {min_value}.'),
          'max_string_length': _('String value too large.')
      }
      MAX_STRING_LENGTH = 1000  # Guard against malicious string inputs.
  
      def __init__(self, **kwargs):
          self.max_value = kwargs.pop('max_value', None)
 
</s>
        'max_string_length': _('String value too large.'),
        'overflow': _('Integer value too large to convert to float')
      default_error_messages = {
          'invalid': _('A valid number is required.'),
          'max_value': _('Ensure this value is less than or equal to {max_value}.'),
          'min_value': _('Ensure this value is greater than or equal to {min_value}.'),
        'max_string_length': _('String value too large.'),
        'overflow': _('Integer value too large to convert to float')
      }
      MAX_STRING_LENGTH = 1000  # Guard against malicious string inputs.
  
      def __init__(self, **kwargs):
          self.max_value = kwargs.pop('max_value', None)
keep keep keep keep replace keep keep keep keep keep
 FloatField will crash if the input is a number that is too big (#8725)

* FloatField will crash if the input is a number that is too big

* Added Unit test for float field overflow error catch

* Removed random import

* Removed additional imported ValidationError

* Update rest_framework/fields.py

* Update tests/test_fields.py

Co-authored-by: Asif Saif Uddin <auvipy@gmail.com>
rest_framework/fields.py