Created
July 22, 2019 20:17
-
-
Save akshar-raaj/980c819ef36adfe6adbd377287036092 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UserSerializer(serializers.ModelSerializer): | |
| class Meta: | |
| model = User | |
| fields = ('email', 'first_name', 'last_name') | |
| def to_representation(self, instance): | |
| representation = super().to_representation(instance) | |
| if instance.is_superuser: | |
| representation['admin'] = True | |
| return representation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment