Django Rest Framework - how to write multiple nested field serializer (for reading & writing)
问题 I'm trying to write a "def create" method to perform nested serialization for multiple objects. def create(self, validated_data): suggested_songs_data = validated_data.pop('suggested_songs') suggest_song_list = list() for song_data in suggested_songs_data: song = Song.objects.create(**song_data) suggest_song_list.append(song) message = Messages.objects.create(suggested_songs=suggest_song_list, **validated_data) return message Here is my schema: class MessagesSerializer(serializers