slice QuerySet and keep as QuerySet

88 views
Skip to first unread message

brian

unread,
Oct 31, 2013, 9:01:49 PM10/31/13
to django...@googlegroups.com

How do I slice a QuerySet and keep it as a QuerySet


If I do

a = qs[:3]

then I get a list back. I want a QuerySet.


I'm wanting to get the first x items in the query set and the last x items in the query set.

Mike Dewhirst

unread,
Oct 31, 2013, 9:55:22 PM10/31/13
to django...@googlegroups.com
On 1/11/2013 12:01pm, brian wrote:
> *How do I slice a QuerySet and keep it as a QuerySet*
>

https://docs.djangoproject.com/en/1.5/ref/models/querysets/#when-querysets-are-evaluated

https://docs.djangoproject.com/en/1.5/ref/models/querysets/#methods-that-return-new-querysets

>
> *If I do*
>
> *a = qs[:3]*
>
> *then I get a list back. I want a QuerySet. *
>
>
> *I'm wanting to get the first x items in the query set and the last x
> items in the query set.*
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b349138c-47f7-41fd-9fcf-db3fba7c40f9%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages