1. here are my models: 2. [10:23 PM] class StreamPlatfrom(models.Model): name = models.CharField(max_length=100) about = models.CharField(max_length=150, null=True) website = models.URLField() id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, unique=True) createdAt = models.DateTimeField(auto_now_add=True) def __str__(self) -> str: return self.name class WatchList(models.Model): title = models.CharField(max_length=150) storyline = models.TextField() active = models.BooleanField() releaseDate = models.DateField() releaseYear = models.IntegerField() stream = models.ManyToManyField(StreamPlatfrom) id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, unique=True) createdAt = models.DateTimeField(auto_now_add=True) def __str__(self) -> str: return self.title
1. 1. and here are my serializer: 2. [10:23 PM] # WatchListSerializer class WatchListSerializer(serializers.ModelSerializer): reviews = ReviewSerializer(many=True, read_only=True) class Meta: model = WatchList fields = ("__all__") depth = 1 def create(self, validated_data): stream_data = validated_data.pop('stream', []) print("Stream_data", stream_data) watchlist = WatchList.objects.create(**validated_data) for stream in stream_data: stream_obj = StreamPlatfrom.objects.get(name=stream['name']) watchlist.stream.add(stream_obj) return watchlist # StreamPlatformSerializer class StreamPlatformSerializer(serializers.ModelSerializer): class Meta: model= StreamPlatfrom fields = ("__all__") 3. [10:23 PM] For some reason the create method is not working 4. [10:24 PM] When I add stream it returns an empty array 2. When I add stream it returns an empty array -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/67e18478-75d0-4ebc-aa81-78b2552bd153n%40googlegroups.com.