Django: Filter objects by integer between two values

后端 未结 2 1362
梦毁少年i
梦毁少年i 2020-12-31 06:09

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

2条回答
  •  孤城傲影
    2020-12-31 06:53

    Try this;

    x = 170
    Dataset.objects.filter(i_end_int__gte=x,i_begin_int__lte=x)
    

    where; gte = greater than equal to lte = less than equal to

提交回复
热议问题