Thursday, June 23, 2011

Re: manytomany query problem

It is very hard to read your message. Please format it appropriately next time. Avoid repeating variable names and mixing classes with instances. Could you post your models here?

Are you defining the following structure:

A hasMany B;
B hasMany A;
B hasMany B;

So you want A such that A.yourB1.yourB2 exists? Sorry for the notation.

On Thu, Jun 23, 2011 at 12:03 PM, Tony <tonyl7126@gmail.com> wrote:
I have two models with a manytomany through relation (A and B).  B has
a self referential manytomany relation (a userprofile model).  How
could I filter objects of model B per each relationship with model A?
So lets say 3 arbitrary model A objects have 20 model B object
relations each.  I want to filter the relations so when I return the
filtered version of model A is outputted, each object of type model A
returns only object Bs (the userprofiles) that are connected through
the self referential manytomany relationship to the userprofile (the
object B, sorry if I use them interchangeably but they are the same
thing) that is currently sending in the request.  I figure out which
userprofile is sending the request with a unique identifier sent by
the user in the request (basically their primary key).  Is this type
of filtering possible.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.




--
Yours,
Nikhil Somaru

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment