I am struggling with a Django filtering problem that I have not been able to solve so far. I have a database with / from integers, and I need a Django filter that returns any objects in which the given integer is within this 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, let's say 170. I need all the objects where 170 is between i_begin_int and i_end_int . In the table of examples, these will be objects with identifiers 1 and 2.
Is there a Django filter that I could use for this?
source share