Hi folks!

Is this possible ?

   In [2]: Place.objects.filter(usual_users__id=1)
   Out[2]: [<Place: Place Jules Guesde>, <Place: Angle rues des
princes et de la tourelles>, <Place: 3 Rue Paul Houette>]

   In [3]: Place.objects.exclude(usual_users__id=1)
   Out[3]: [<Place: Angle rues des princes et de la tourelles>,
<Place: 175 Boulevard Jean Jaurès>]

AFAIU, exclude(<my_condition>) generates an SQL clause like '... where
not(<my_condition>)' whereas filter(<my_condition>) generates '...
where <my_condition>'. So my object '<Place: Angle rues des princes et
de la tourelles>' can't appear in both queryset, right?

It seems like a bug to me but I'm very new to django so it might be my
lack of experience as well! :) Does anyone can help ?

Maybe I should give you a few more details. Here are some excerpts of
my model :

   class Place(models.Model, models.GeoMixin):
      name = models.CharField(max_length = 100)
      geometry = models.PointField(srid = 27572)
      objects = models.GeoManager()
      ...

   class User(models.Model):
      nickname = models.CharField(max_length = 50)
      phone_number = models.CharField(max_length = 15)
      email = models.EmailField()
      usual_places = models.ManyToManyField(Place, related_name =
"usual_users")
      objects = models.GeoManager()
      ...

Note 1: I use the GeoDjango extension
Note 2: I can provide the whole model if required

I noticed something weird in the underlying database. The join table
app_user_usual_place has 3 columns : id, user_id and place_id. Is it
possible that my condition usual_users__id refer to the id field of
the join table ?

Regards,
Gilles Bassiere
http://www.makina-corpus.com


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to