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.

Could you help me get the right code for what I want?

Many thanks!

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