我正在将一个新对象重新分配给movie
。我想将新对象追加到movie
。我该怎么办?
for language in categories.language.all():
movie = Movie.objects.filter(is_active=True,language=language.id)
谢谢你
更新:在categories.language.all()
我反对这样的话。
English
Etc
French
我想用这些语言过滤Movie
模型。
MYSQL查询> select * from move where language = 'English' and language = 'French'
答案 0 :(得分:0)
您最好使用in:
languages = [ language.id for language in categories.language.all() ]
movies = Movie.objects.filter(is_active=True, language__in=languages)
假设categories.language.all()
返回一个QuerySet(我们无法从你的问题中得知),它甚至更简单:
languages = categories.language.all()
movies = Movie.objects.filter(is_active=True, language__in=languages)