3👍
✅
you can use SerializerMethodField:
class CurrentUserSerializer(serializers.ModelSerializer):
role = serializers.SerializerMethodField('is_super')
def is_super(self, user):
return "ADMIN" if user.is_superuser else "WHATEVER"
class Meta:
model = User
fields = ('role', 'username', 'email', 'id','first_name','last_name',"is_staff","is_superuser")
Source:stackexchange.com