Nenad Cikic
unread,May 9, 2012, 12:16:44 AM5/9/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
Hello!
I am trying to undestand how to limit visible rows in change view. It seems to me a common need, but can not find info in django docs.
I am using the admin interface.
So I have one model and his admin is something as:
ordering = ('-datum','krajnjikorisnik','tipimpulse','impulsecijena')
def queryset(self, request):
qs=super(KrajnjiKorisnikImpulseAdmin, self).queryset(request)
qs=qs.filter(bla bla bla)
return qs
With the queryset of above I filter just the needed rows. I have check with postgre log, and indeed the correct SELECT statement is generated.
Now I want to get just the top x elements.
I continue to get
"Cannot reorder a query once a slice has been taken."
or
"Cannot filter a query once a slice has been taken."
I have tried to change my queryset function to:
1.
def queryset(self, request):
qs=super(KrajnjiKorisnikImpulseAdmin, self).queryset(request)[0:2]
qs=qs.filter(bla bla bla)
return qs
2. i have treid to manually construct the queryset for testing purpose as:
def queryset(self, request):
qs=KrajnjiKorisnikImpulse.objects.all()[0:2]
return qs
and i have also commented the ordering statement
Both are giving the above errors. Is not limiting the rows a common feature one might want, or is not relevant since admin views have pages?
Thanks
Nenad