I guess I should have made this more clear what my question was:

Anybody know how to fix the WHERE clause?  Is there a better way to
achieve this functionality?

On Mar 17, 3:44 pm, Charlie L <charleslei...@gmail.com> wrote:
> I'm running into some trouble adding a custom many-to-many field to
> the User model.
>
> http://dpaste.com/173041/
>
> I am modelling social relationships, and to do this I have a
> relationship model with 2 foreign keys to users, a 'from_user' and a
> 'to_user' -- in essence, this looks like a Many-to-many table between
> users and can probably act like one.
>
> So what I'm trying to do is, mimicking django's
> ManyRelatedObjectsDescriptor, create a RelatedManager dynamically that
> will access the relationship table.
>
> It's almost working right, except for the last part of the WHERE query
> that's being generated:
>
> In [5]: co = User.objects.get(username='coleifer')
>
> In [6]: co.relationships.all()
> Out[6]: []
>
> In [8]: connection.queries.pop()
> Out[8]:
> SELECT "auth_user"."id", etc, etc
> FROM "auth_user"
> INNER JOIN "relationships_relationship"
>   ON ("auth_user"."id" = "relationships_relationship"."from_user_id")
> WHERE "relationships_relationship"."id" = 69327
> LIMIT 21
>
> the where should read "relationships_relationshpi"."to_user_id" =
> 69327

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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