Django filter through multiple fields in a many-to-many intermediary table

后端 未结 3 936
闹比i
闹比i 2021-02-19 06:15

I have the following models in my django project:

class Video(models.Model):
    media = models.ForeignKey(Media)

class Media(models.Model):
    title = models.         


        
3条回答
  •  时光说笑
    2021-02-19 06:21

    You can chain the filters together for an "AND" construct.

    Videos where the format is f AND the format's status is 10

    Video.objects.filter(media__formats=f).filter(media__mediaformat__status=10)
    

提交回复
热议问题