Hi all guys. I would have expected a different behaviour about filtering a QuerySet in some cases.
Here's a model UserSearch having a field named "public" and a "user" one. I get all my searches plus the public ones by the other users. ss = UserSearch.objects.filter(user = me) | UserSearch.objects.filter(public = True) Let's suppose the QuerySet has 4 searches of mine and 1 public by another user. Now I want just differ mines from the other user ones. mysearches = ss.filter(user = me) publicsearches = ss.exclude(user = me) mysearches.count() gives 4!!!! publicsearches.count() gives 1. right. This happens because the sql query of ss is something like : """select * from usersearches where user = "me" or public = 1""" The query filtering for mysearches is identical to the previous one! where maybe i expected something like """select * from usersearches where (user = "me" or public = 1) and user="me" """ The query filtering for the public ones is, as I exptected, something like """select * from usersearches where (user = "me" or public = 1) and not user="me" """ Just why? I suppose if I apply a filter, all the previous filters should go between "( )", then the new filter is applied with a "and" or "and not" or whatever. Thank you. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---