Created
August 10, 2018 02:40
-
-
Save issackelly/fd701dcb789a07c7d17bdd64d879e425 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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