0π
β
For genres: You can use values_list
.
Try this in your get_genres:
def get_genres(self, obj):
return MovieGenre.objects.filter(movie=obj).values_list('genre', flat=True)
I assume that the genre
is the field name of MovieGenre model.
And for the movie key β as it is currently in your question β there should not be any movie key. Your serializer does not have it. So i cant see why you have the output unless there is something else you did not include.
The serializer should producer list of serialized movie objects.
Try to remove StandardResultsSetPagination
and see if it is correct.
Source:stackexchange.com