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 theserializer
.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
Source:stackexchange.com