I have a list that looks like this:
list = Device.objects.all().order_by('parent', 'name')
and I use this list in a view. Works fine. However, I want to
have the items with a special name at the top of the generated
list. I can easily create two lists, which have the two items in
it:
list1 = Device.objects.all().
filter(name__istartswith='New device')
list2 = Device.objects.all().
exclude(name__istartswith='New device').
order_by('parent', 'name')
However, I can't find a way to join them into one list. This did
not work:
pag = ObjectPaginator(list1 or list2, 50)
And besides, or would use QuerySet.__or__ which would use
QuerySet._combine, and that would merely intermix inter object
parameters of the not-yet-evaluated QuerySets.
list = []
list.extend(list1)
list.extend(list2)
pag = ObjectPaginator(list1 or list2, 50)
I also can't solve my problem at the template level:
{% for item in list1 %}
item.foo<br>
{% endfor %}
{% for item in list2 %}
item.foo<br>
{% endfor %}
... because this wouldn't work with ObjectPaginator.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---