 <p>Outer joins can be viewed as a hack because SQL lacks "navigation". </p> <p>What you have is a simple if-statement situation.</p> <pre><code>for line in someRangeOfLines: for col in someRangeOfCols: try: cell= FooVal.objects().get( col = col, line = line ) except FooVal.DoesNotExist: cell= None </code></pre> <p>That's what an outer join really is -- an attempted lookup with a NULL replacement.</p> <p>The only optimization is something like the following.</p> <pre><code>matrix = {} for f in FooVal.objects().all(): matrix[(f.line,f.col)] = f for line in someRangeOfLines: for col in someRangeOfCols: cell= matrix.get((line,col),None) </code></pre>