python - limit bandwidth of queryset results according to an order django orm -
i have model colleges field rank.
input college object rank 10.(lets object xyz)
colleges ranked , same rank can assigned different colleges.
want return colleges objects (max = 10) 5 colleges having score less xyz's rank , 5 colleges greater college's rank in sorted manner.
not want bring colleges first , select 10 colleges out of because huge data.
there way make direct query via django orm??
django 1.6 platform.
for example have 100 objects rank 1-20. , college xyz lie in 35th position in sorted order. colleges woth 30-34 , 36-40 should show up
the problem discussing here dont need custom sql query, if still need check here help
# custom query inside `raw` function c in college.objects.raw('select * appname_college')[:5]: print(c)
but can use filter
above situation & if conditions more use condition expressions
Comments
Post a Comment