I'm struggling with a Django filtering problem I couldn't solve so far. I have a database with from/to integers, and I need a Django Filter that returns any objects where a given integer is within that range.
I have the following model (simplified):
class Dataset(models.Model):
i_begin_int = models.BigIntegerField()
i_end_int = models.BigIntegerField()
So for example, I have the following data:
+----+-------------+-----------+
| id | i_begin_int | i_end_int |
+----+-------------+-----------+
| 1 | 100 | 200 |
+----+-------------+-----------+
| 2 | 150 | 300 |
+----+-------------+-----------+
| 3 | 7000 | 7500 |
+----+-------------+-----------+
So now I have an integer, lets say, 170. I need all objects where 170 is between i_begin_int
and i_end_int
. In the example table, that would be objects with id 1 and 2.
Is there a Django filter that I could use for this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…