检查值范围

时间:2018-08-11 14:40:11

标签: django

我可以使用BETWEEN运算符检查值的范围。

MySQL [distributor]> select prod_name, prod_price from products where prod_price between 3.49 and 11.99;
+---------------------+------------+
| prod_name           | prod_price |
+---------------------+------------+
| Fish bean bag toy   |       3.49 |
| Bird bean bag toy   |       3.49 |
| Rabbit bean bag toy |       3.49 |
| 8 inch teddy bear   |       5.99 |
| 12 inch teddy bear  |       8.99 |
| 18 inch teddy bear  |      11.99 |
| Raggedy Ann         |       4.99 |
| King doll           |       9.49 |
| Queen doll          |       9.49 |
+---------------------+------------+
9 rows in set (0.005 sec)

我参考了django文档,发现gtegtltlte,但没有between

如何实现两者之间的功能?

1 个答案:

答案 0 :(得分:1)

在Django ORM products.objects.filter(prod_price__range=(3.49 , 11.99)) ref for more info

中使用它