3👍
✅
you can make your User Serializer like this:
class UserSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = [...] # put your fields instead of "..."
depth = 1
and then use nested serializer like this :
class PostSerializer(serializers.ModelSerializer):
author = UserSerializer(many=false)
class Meta:
fields = ('id','body','created_at')
model = Post
Source:stackexchange.com