Skip to content

Instantly share code, notes, and snippets.

@issackelly
Created August 10, 2018 02:40
Show Gist options
  • Save issackelly/fd701dcb789a07c7d17bdd64d879e425 to your computer and use it in GitHub Desktop.
Save issackelly/fd701dcb789a07c7d17bdd64d879e425 to your computer and use it in GitHub Desktop.
class Track(models.Model):
name = models.CharField()
is_deleted = models.BooleanField(default=False)
album = models.ForeignKey(Album, related_name="tracks")
class Album(models.Model):
name = models.CharField()
class TrackSerializer(serializers.ModelSerializer):
class Meta:
model = Track
class AlbumSerializer(serializers.ModelSerializer):
tracks = TrackSerializer(many=True)
### How do I limit tracks in the related/nested serializer to tracks on this album that have not been deleted?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment