Skip to content

Commit 0b72285

Browse files
author
Ryan P Kilby
committed
Test current behavior of exclude+declared field
1 parent 265375c commit 0b72285

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/test_model_serializer.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,16 @@ class Meta:
900900
"Cannot set both 'fields' and 'exclude' options on serializer ExampleSerializer."
901901
)
902902

903+
def test_declared_fields_with_exclude_option(self):
904+
class ExampleSerializer(serializers.ModelSerializer):
905+
text = serializers.CharField()
906+
907+
class Meta:
908+
model = MetaClassTestModel
909+
exclude = ('text',)
910+
911+
assert list(ExampleSerializer().fields) == ['id', 'text']
912+
903913

904914
class Issue2704TestCase(TestCase):
905915
def test_queryset_all(self):

0 commit comments

Comments
 (0)