[Answered ]-Select middle rows in Django ORM

2👍

Try this:

someTable.objects.all()[r:r+n]

This is just like normal lists:

In [10]: t = range(1,10)

In [11]: r = 2

In [12]: n = 3

In [13]: t[r:r+n]
Out[13]: [3, 4, 5]

Django will transform this into SQL query with limit.

Leave a comment