我正在尝试相当于这个SQL查询:
"SELECT * FROM something WHERE ((something >= something AND something <= something) AND(something >= something AND something <= something))"
我无法弄明白。我试过以下但没有成功..
.filter(( Q(something__gte=something) & Q(something__lte=something)) & ( Q(something__gte=something) & Q(something__lte=something)))
.filter( Q(something__gte=something,something__lte=something) & Q(something__gte=something,something__lte=something))
都会返回以下内容..并完全忽略我的括号......
WHERE (`something`.`something` >= something AND `something`.`something` <= -something AND `something`.`something` >= something AND `something`.`something` <= something )
答案 0 :(得分:3)
逻辑运算符AND是关联的。 a&amp; b&amp; c ==(a&amp; b)&amp; c == a&amp; (b&amp; c)。不需要括号