Add LogEntry to endpoint and retrieve changes in django rest for each user activity

Viewed 68

I am trying to add user activity log using the django built in model LogEntry.

In this application I am using simpleJWT to authenticate using token.

However the changes are not appearing on the api when you are logged using the token authentication. I've seen that only when I am logged in admin that I can see the changes, both in the admin and the LogEntry endpoint.

# serializers.py ----

class LogEntrySerializer(serializers.ModelSerializer):

    class Meta:
        model = LogEntry
        fields = '__all__'

# viewsets.py ----

class LogEntryViewSet(viewsets.ModelViewSet):
    queryset = LogEntry.objects.all()
    serializer_class = LogEntrySerializer

I know that there are packages such as django-simple-history that may help me with this issue. However I want to pass all of the user activity logs into the LogEntry model but I have no clue how to do this approach without adding a query into each method for each endpoint.

0 Answers
Related