I have the following models in my django project:
class Video(models.Model):
media = models.ForeignKey(Media)
class Media(models.Model):
title = models.
Now, I want to filter all videos which have a specific format, AND the status code for that format is 10 (ready to use). How can I do that? (assuming that f is the format)
The code you posted will do exactly what you want:
Video.objects.filter(media__formats=f, media__mediaformat__status=10)
This is documented in the filter() documentation:
Multiple parameters are joined via AND in the underlying SQL statement.