                      # `view_name` is only valid for hyperlinked relationships.
                      if not issubclass(field_cls, HyperlinkedRelatedField):
                          kwargs.pop('view_name', None)
  
              else:
                  assert False, 'Field name `%s` is not valid.' % field_name
  
              ret[field_name] = field_cls(**kwargs)
  
          return ret
  
 
</s> remove from django.core.exceptions import ValidationError
 </s> add from django.core.exceptions import ImproperlyConfigured, ValidationError
            elif hasattr(model, field_name):
                # Create a read only field for model methods and properties.
                field_cls = ReadOnlyField
                kwargs = {}
                      # `view_name` is only valid for hyperlinked relationships.
                      if not issubclass(field_cls, HyperlinkedRelatedField):
                          kwargs.pop('view_name', None)
  
            elif hasattr(model, field_name):
                # Create a read only field for model methods and properties.
                field_cls = ReadOnlyField
                kwargs = {}
            elif hasattr(model, field_name):
                # Create a read only field for model methods and properties.
                field_cls = ReadOnlyField
                kwargs = {}
  
              ret[field_name] = field_cls(**kwargs)
  
          return ret
  
keep keep keep keep replace replace keep keep keep keep keep
 Configuration correctness tests on ModelSerializer 
rest_framework/serializers.py