Re: Reverse M2M

2007-02-07 Thread Enrico
Hi Ross, The empty Q is the same thing as nothing, no filter. I need to filter the query according to the options the user checks on the form. So this line: (form.data.get('my') and Q(friends_set=request.user.id) or Q()) means: (if checkbox 'my' is checked filter using (friends_set=request.us

Re: Reverse M2M

2007-02-07 Thread [EMAIL PROTECTED]
Hi, I've been following this thread to learn Django better. Could you explain what the function of the empty Q is in your code, Enrico? What does 'or Q()' do? Cheers, Ross On Feb 7, 7:19 am, "Enrico" <[EMAIL PROTECTED]> wrote: > Hi Russel, > > Thanks a lot, it worked now. > > I can't drop the

Re: Reverse M2M

2007-02-07 Thread Enrico
Hi Russel, Thanks a lot, it worked now. I can't drop the related_name clause, in the Profile model I have two relationships to the User model: user (OneToOne) and friends (M2M). Then Django complains that the reverse query names clashes on those fields, forcing me to use a related_name. If I us

Re: Reverse M2M

2007-02-06 Thread Russell Keith-Magee
On 2/6/07, Enrico <[EMAIL PROTECTED]> wrote: > > Hi Russel, > > I think that it doesn't solve the problem. > > I can use your solution to get my friends. But I need to include > people who added me in the same listing. > > To get a list of people who added me I can use: > people_who_added_me = > a

Re: Reverse M2M

2007-02-06 Thread Enrico
Hi Russel, I think that it doesn't solve the problem. I can use your solution to get my friends. But I need to include people who added me in the same listing. To get a list of people who added me I can use: people_who_added_me = auth.models.User.objects.filter(profile__friends=my_id) My probl

Re: Reverse M2M

2007-02-05 Thread Russell Keith-Magee
On 2/5/07, Enrico <[EMAIL PROTECTED]> wrote: > > I need to list the Users, with the possibility of using two filters: > my friends and people who added me. > > I can list people who added me using: > users = auth.models.User.filter(profile__friends=some_user_id) > > But I can't get the list of peo

Reverse M2M

2007-02-05 Thread Enrico
Hi, I have a Profile model with a OneToOne relationship to the auth.User model. In the Profile I have a ManyToMany relationship (non-symmetrical) to the auth.User model called friends. Something like this: class Profile(models.Model): user = models.OneToOneField(auth.models.User) friends