>>> class UserSerializer(DynamicFieldsModelSerializer):
>>> class Meta:
>>> model = User
>>> fields = ['id', 'username', 'email']
>>>
>>> print(UserSerializer(user))
{'id': 2, 'username': 'jonwatts', 'email': 'jon@example.com'}
>>>
>>> print(UserSerializer(user, fields=('id', 'email')))
{'id': 2, 'email': 'jon@example.com'}
>>> print(UserSerializer(user, exclude_fields=('id')))
{'username': 'jonwatts', 'email': 'jon@example.com'}
-
Notifications
You must be signed in to change notification settings - Fork 0
DynamicFieldsModelSerializer with exclude_fields functionality
License
UmarFarooq-Ch/Django-DynamicFieldsModelSerializer
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
DynamicFieldsModelSerializer with exclude_fields functionality
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published