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

后端 未结 3 915
闹比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:42

    Probably not relevant for the OP, but might be for others like me who found this thread while searching for the right answer.

    Ludwik got it right, but the section in the documentation that explains all of this, as well as how to do excludes, is in the queries documentation.

    Note that splitting the filter into two filter calls like Chris suggested will give you the exact opposite result: it will search for a video that has a media format f and that has a media format, not necessarily the same media format, with a status of 10.

提交回复
热议问题