Thank you, Gianluca.

Unfortunately, filter() has no direct impact on joins configuration
and conditions described in filter() go to WHERE clause.
When you refer another table it will be joined somehow but with only
one equality expression in the condition.
We were discussing join consitions here, which go in ON() in FROM
clause.

Alexander.

On 2 июл, 14:53, Gianluca Sforna <gia...@gmail.com> wrote:
> On Thu, Jun 30, 2011 at 5:19 PM, peroksid <alexander.pugac...@gmail.com> 
> wrote:
>
> > I need to have for the "ON" expression slighlty more complex
> > expression, something like
> > "left_table.left_column=right_table.right_column AND
> > right_table.another_column=42". Method join() obviously  can not be
> > used for this purpose because it tuple defining join connection
> > consists off 4 elements.
> > I suspect there is no way to create such a double join condition at
> > all, event without constant involved instead of column.
>
> Maybe you can use F objects to create the correct filters? It would be
> something like:
>
> object_list = 
> ObjectModel.filter(sometable__leftcolumn=F('right_table__right_column'))
>
> and then you can use Q objects to combine two of them:
>
> q1 = Q(sometable__leftcolumn=F('right_table__right_column'))
> q2 = Q(right_table__another_column=42)
>
> object_list = ObjectModel.filter(q1 & q2)
>
> more info 
> at:https://docs.djangoproject.com/en/dev/topics/db/queries/#filters-can-...https://docs.djangoproject.com/en/dev/topics/db/queries/#complex-look...
>
> --
> Gianluca Sforna
>
> http://morefedora.blogspot.comhttp://identi.ca/giallu-http://twitter.com/giallu

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

Reply via email to