django无法过滤超过一个学期

时间:2012-10-25 20:00:18

标签: django filter django-views

design_list = Design.objects.filter(tags__tag__contains='jewellery')

如果我添加一个过滤条件(如下),则返回'keyword argument repeated'

design_list = Design.objects.filter(tags__tag__contains='jewellery', tags__tag__contains='gadget')

如何添加更多条款?

1 个答案:

答案 0 :(得分:1)

您必须使用Q objects才能进行OR查询:

from django.db.models import Q
Design.objects.filter(Q(tags__tag__contains = "jewellery") | Q(tags__tag__contains = "gadget"))