I need only 5th and 30th record (from top) in the below query set?
qs=Posts.objects.filter().orderby('-date')
is there any rownum functionality available in django to achieve this in a single query like rownum=5 ??.
Note: I am using Postgres
I need only 5th and 30th record (from top) in the below query set?
qs=Posts.objects.filter().orderby('-date')
is there any rownum functionality available in django to achieve this in a single query like rownum=5 ??.
Note: I am using Postgres
Typecast the queryset into a list then perform normal list indexing to get the desired results. Just use
q = list(qs)
However this is not efficient as it may eat some memory depending on the size of the query set, so other methods you may refer - How to convert a Django QuerySet to a list