On 6 Mar, 00:04, Darthmahon <[EMAIL PROTECTED]> wrote: > Ahh ok. Something like this then? > > qset = (Q(tags__title__icontains=query) | Q(title__icontains=query)) > results = Blog.objects.filter(qset).extra(LEFT OUTER JOIN tag ON > blog.tag = tag.id) No, because if you use 'tags__title__icontains' it will create SQL that expects tag to exist. Should be something like:
Blog.objects.extra(tables=['APP_tags as B'], where=[''APP_blog.id is null or APP_blog.id=B.blog_id', "B.title ilike '%%%s%%' or title ilike '%%%s%%'"], params=[query, query]) I'm not sure if above will work, especially quoting % signs may be wrong. You should try to write working SQL first and then try to use it with extra. If you're using postgres you may enable logging of sql statements in database params and see what is executed. -- Maciej Wisniowski --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---