Re: DB API - filter/exclude bug ?

2007-10-07 Thread Justin Bronn

> So my object ' de la tourelles>' can't appear in both queryset, right?

Not necessarily.  For example, if you had a Place ("Paris"), it may be
associated with multiple users because of the ManyToManyField
("M2M").   In this case let's say Bob and Jane both have a M2M entries
to Paris.  When you filter excluding Bob's id, Jane's Place M2M entry
is associated with a _different_ id, and thus the query will perform
as you described above -- and still include the Paris entry associated
with Jane's id.

Check to see if you have multiple User models associated w/the 'Angle
rues des princes et de la tourelles' place, for example, by performing
the following query:

qs = User.objects.filter(usual_places__name='Angle rues des princes et
de la tourelles' )

-Justin


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



DB API - filter/exclude bug ?

2007-09-26 Thread gilles . bassiere

Hi folks!

Is this possible ?

   In [2]: Place.objects.filter(usual_users__id=1)
   Out[2]: [, , ]

   In [3]: Place.objects.exclude(usual_users__id=1)
   Out[3]: [,
]

AFAIU, exclude() generates an SQL clause like '... where
not()' whereas filter() generates '...
where '. So my object '' 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
-~--~~~~--~~--~--~---