disallow same field name in both exclude and include.

This commit is contained in:
Ignacio Gonzalez 2023-03-19 15:23:11 -03:00
parent d0179995f0
commit d13cd397b6

View File

@ -1130,6 +1130,13 @@ class ModelSerializer(Serializer):
)
)
assert set(exclude or []).isdisjoint(include or []), (
"Cannot set the same field name in both 'exclude' and 'include' options "
"on serializer {serializer_class}.".format(
serializer_class=self.__class__.__name__
)
)
# TODO Review the message of this assertion.
assert not (fields is None and exclude is None and include is None), (
"Creating a ModelSerializer without either the 'fields', 'exclude' "