A solution with raw
might look like
foos = Foo.objects.raw("SELECT foo.* FROM foo LEFT OUTER JOIN userfoo ON (foo.id = userfoo.foo_id AND foo.user_id = %s)", [request.user.id])
You’ll need to modify the SELECT
to include extra fields from userfoo
which will be annotated to the resulting Foo
instances in the queryset.