On Sun, 2008-02-10 at 23:14 -0800, Julien wrote: > Hi there, > > I'd like to pull out all the projects that a given user is involved > in, either as a creator or as a participant of the projects: > > class Project(models.Model): > name = models.CharField(max_length=200) > created_by = models.ForeignKey(User) > > class Participant(models.Model): > project = models.ForeignKey(Project) > user = models.ForeignKey(User) > > I'm running the following code: > > q1 = Project.objects.filter(created_by=user) > q2 = Project.objects.filter(participants__user=user) > projects = q1 | q2 > > Unfortunately it doesn't return what I'd expect. > q1 and q2 work individually, but q1 | q2 returns a strange list of > projects. By "strange" I mean that I can't figure out what reasoning > is going on to provide that result.
What is the SQL statement being executed (have a look in the FAQ if you don't know how to view the SQL statement). There are some bugs in 'or' combinations. I don't know if you're hitting one of those or not. Regards, Malcolm -- Tolkien is hobbit-forming. http://www.pointy-stick.com/blog/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---