diff --git a/program/serializers.py b/program/serializers.py index 6f6c5c3a88e1cb27016c0b4771e81553034e27e2..68f3371d0a860ae9404e9b4c95902eb47512119e 100644 --- a/program/serializers.py +++ b/program/serializers.py @@ -274,12 +274,12 @@ class ShowSerializer(serializers.HyperlinkedModelSerializer): show = Show.objects.create(**validated_data) # Save many-to-many relationships - show.owners = owners - show.category = category - show.hosts = hosts - show.language = language - show.topic = topic - show.musicfocus = musicfocus + show.owners.set(owners) + show.category.set(category) + show.hosts.set(hosts) + show.language.set(language) + show.topic.set(topic) + show.musicfocus.set(musicfocus) show.save() return show @@ -306,12 +306,12 @@ class ShowSerializer(serializers.HyperlinkedModelSerializer): # Only superusers may update the following fields if user.is_superuser: - instance.owners = validated_data.get('owners', instance.owners) - instance.category = validated_data.get('category', instance.category) - instance.hosts = validated_data.get('hosts', instance.hosts) - instance.language = validated_data.get('language', instance.language) - instance.topic = validated_data.get('topic', instance.topic) - instance.musicfocus = validated_data.get('musicfocus', instance.musicfocus) + instance.owners.set(validated_data.get('owners', instance.owners)) + instance.category.set(validated_data.get('category', instance.category)) + instance.hosts.set(validated_data.get('hosts', instance.hosts)) + instance.language.set(validated_data.get('language', instance.language)) + instance.topic.set(validated_data.get('topic', instance.topic)) + instance.musicfocus.set(validated_data.get('musicfocus', instance.musicfocus)) instance.type = validated_data.get('type', instance.type) instance.fundingcategory = validated_data.get('fundingcategory', instance.fundingcategory) instance.predecessor = validated_data.get('predecessor', instance.predecessor) @@ -466,4 +466,4 @@ class NoteSerializer(serializers.ModelSerializer): except ObjectDoesNotExist: pass - return instance \ No newline at end of file + return instance