Thanks so much for the reply.

Oddly the method you suggests throws an error but I'm not sure why.

The solution I came up with is as follows:

User.objects.order_by('username').filter
(project__owner__isnull=False).distinct() | User.objects.filter
(release__owner__isnull=False).distinct()

I would expect the line you wrote to give the same results but when I
try it I get an Template Error of "Caught an exception while
rendering: no such column: U1.owner_id"  I have no idea why.

It's working for me so I don't have a problem now but I'm definitly
missing something about why I'm getting this error at all.

Thanks again for the reply.

On Jun 9, 2:43 pm, googletorp <toppe...@gmail.com> wrote:
> You can do
>
> Users.objects.exclude(project__owner__isnull=True,
>                              other__model__isnull=True).distinct()
>
> ~Jakob
>
> On Jun 9, 7:49 pm, Streamweaver <streamwea...@gmail.com> wrote:
>
> > I have two models with Foreign Key relationships to Users and what I'm
> > looking to do is reterive a unique list of users from both Models.
>
> > class Project(models.Model):
> >     owner = models.ForeignKey(User)
>
> > class Release(models.Model):
> >     owner = models.ForeignKey(User)
>
> > I know I can retrieve a distinct list of users from either by spanning
> > relationships. (using Projects as an example)
>
> > Users.objects.filter(project__owner__isnull=False).distinct()
>
> > But how would I get a distinct set of Users who are owners of Projects
> > OR Releases?
>
> > Thanks for any insight.
--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to