On 1/28/07, Ramashish Baranwal <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I would like to restrict a QuerySet based on its ManyToManyField. In
> particular, based on what the ManyToManyField contains. Consider this
> trivial and a bit non-sense example-
>
> class User:
>     name = models.CharField(maxlength=24)
>     related = models.ManyToManyField('self', symmetric=False)
>
> I want to get Users who are related to other users whose names start
> with 'A'. e.g.
>
> pplA = User.objects.filter(name__starts_with='A')
>
> # The below doesn't result in what I expect.
> #relatedA = User.objects.filter(related__in=ppl)
>
> I am looking for a clause that can help me accomplish this but ain't
> able to find in docs.
>

There have been a couple of typos in my earlier Post. Sorry for that,
the correctected version is-

I would like to restrict a QuerySet based on its ManyToManyField. In
particular, based on what the ManyToManyField contains. Consider this
trivial and a bit non-sense example-

class User:
   name = models.CharField(maxlength=24)
   related = models.ManyToManyField('self', symmetric=False)

class User(models.Model):
   name = models.CharField(maxlength=24)
   related = models.ManyToManyField('self', symmetric=False)

I want to get Users who are related to other users whose names start
with 'A'. e.g.

pplA = User.objects.filter(name__starts_with='A')

# The below is for illustration only, it doesn't do what I expect.
#relatedA = User.objects.filter(related__in=pplA)

I am looking for a clause that can help me accomplish this but ain't
able to find in docs. Please note that the users in relatedA might
also be related to other users not in pplA too, all I want is they
should atleast be related to one user in pplA.

Thanks,
-Ram

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