- I'm creating a search functionality that returns all model fields like - users, posts, hashtags, images, and videos.
- I'm trying to create multiple queryset with their multiple serializers to return in a single response.
this is my expected response result.
{
searchresults{
posts[
],images[
],videos[
],user[
]
}
}
- I tried many methods to do this, but the response was unsuccessful.
- I also tried that one but that required relationship.
class HashTagResponseSerializer(serializers.ModelSerializer):
class Meta:
model = HashtagName
fields = ["hashtag",]
def get_hashtag(self, obj):
...
class UserFollowSerializer(serializers.ModelSerializer):
hashtag = HashTagResponseSerializer(many=True, read_only=True)
class Meta:
model = User
fields = ['user_uuid', 'post_language', "username", "display_name",
"profile_picture", "hashtag "]