diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index 8de22f4b9..ed709d848 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -880,6 +880,10 @@ class ModelSerializer(Serializer): exclude = getattr(self.Meta, 'exclude', None) if exclude is not None: for field_name in exclude: + assert field_name in fields, ( + 'The field in the `exclude` option must be a model field. Got %s.' % + field_name + ) fields.remove(field_name) # Determine the set of model fields, and the fields that they map to.