Serializer returning empty Strings in a Django Project while displayed in Json

I have a serializer and in a django which I am trying to access from flutter app. But the issue is that in the json I can see the string available but when it is called it is not showing any results.

Here is the serializer:

class ActiveSessionSerializer(serializers.ModelSerializer):
    class Meta:
        model = ActiveSession
        fields = '__all__'

    def __init__(self, queryset, *args, **kwargs):
        print(f'queryset: {queryset}')
        self.queryset = queryset
        super(ActiveSessionSerializer, self).__init__(*args, **kwargs)

    def to_representation(self, instance):
        print(f'instance: {instance}')
        return super(ActiveSessionSerializer, self).to_representation(instance)

Here is the json:

        "session_workout": "Lower1Updated",
        "activated": false,

but in the

def getActiveSession(request, **kwargs):
    last_active_session = ActiveSession.objects.filter(user=user).latest('id')
    serializer = ActiveSessionSerializer(last_active_session, many=False)
    print(f"Serialized active session data: {}")
    return Response(

The result of the is the following:

Serialized active session data: {'activated': False, 'session_workout': ''}

My question what is the reason for showing empty string in the while in the json data there is data populated. How to fix this error ?

Back to Top