Complex 'AND' Django Queries
I'm trying to do the equ开发者_开发百科ivalent of this SQL query:
"SELECT * FROM something WHERE ((something >= something AND something <= something) AND(something >= something AND something <= something))"
And I can't quite figure it out. I've tried the following with no success..
.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))
both returns the following.. and completely ignores my brackets...
WHERE (`something`.`something` >= something AND `something`.`something` <= -something AND `something`.`something` >= something AND `something`.`something` <= something )
the logical operator AND is associative. a & b & c == (a & b) & c == a & (b & c). No parentheses are needed
精彩评论