Hi all, Is there a way to switch django's relationship building from INNER JOIN to LEFT OUTER JOIN ? It causes unexpected behaviour when filtering on both parent and child tables.
For instance, let's say my models are : class Collection(model): name = CharField() class Book(model): title = CharField() collection = ForeignKey(Collection, blank = True, null = True) A Book may or not belong to a Collection, so some instances have a collection foreign key set to null. Now, if I want to get all books related to cooking (including 'Marvelous Puddings' in the collection 'Traditional british cooking') , I would build a queryset like : mybooks = Book.objects.filter(title__icontains = 'cooking').filter(collection__name__icontains = 'cooking') But this won't return books which title contains 'cooking' indeed, but don't belong to a collection ( the corresponding records won't be picked by the INNER JOIN, whereas a LEFT OUTER JOIN would have done the job). So, is there any way to go around this ? The only hack I have in mind is get the sql, replace INNER JOIN by LEFT OUTER JOIN, but, gee, that's ugly... Regards, Olivier --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---