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-reference-fields-on-the-model https://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects -- Gianluca Sforna http://morefedora.blogspot.com http://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.