[Answered ]-How to add a static User field to django query

2👍

Have a look at the CurrentUserDefault:

A default class that can be used to represent the current user. In order to use this, the 'request' must have been provided as part of the context dictionary when instantiating the serializer.

owner = serializers.HiddenField(
    default=serializers.CurrentUserDefault()
)

To use this, you need to pass the request in the context as following:

serializer = AccountSerializer(account, context={'request': request})
👤AKS

Leave a comment