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 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 use 'friends_set' in the related_name, it works, and it really is
> easier to understand.
>
> I ended up using something like this:
>
> lookup = (
> # My friends
> (form.data.get('my') and Q(friends_set=request.user.id) or Q()) |
> # People who added me
> (form.data.get('who') and Q(profile__friends=request.user.id) or
> Q())
> )
>
> Best regards,
> Enrico
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---