Let's say I have a list of words in my database:
['bbb', 'aaa', 'zzz', 'ddd']
How can I retrieve a list of the above excluding the following words
['aaa', 'zzz'] by using __in? I can do the above with:
words_list = Words.objects.exclude(
Q(word_name = 'aaa') | Q(word_name = 'zzz')
)
The following type of syntax doesn't seem to work with exclude but
works with filter:
exclude_list = ['aaa', 'zzz']
country _list = Countries.objects.exclude(word_name__in =
exclude_list)
The other operation I want to do is to construct a list where I hand
pick two items and place it at the beginning of a list while the rest
is sorted. For example, if I want 'zzz' and 'ddd' to be at the
beginning of the list while the rest is sorted, my desired output will
look like:
['zzz', 'ddd', 'aaa', 'bbb']
I could do the above in 2 steps but I end up with two QuerySet objects
which I cannot join together. Any help on the above?
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---