niwibe/djorm-ext-expressions — pull request #4 by takinbo (2013-02-11 12:19:53+00:00)
Title: added support for fields that create table aliases referencing the same database table as the parent model

This is especially useful for foreign key references
that point to the same model a.k.a ForeignKey('self')

The Django ORM will create an alias but this doesn't get
used and so the query fails to perform lookup references
on the actual target field. This commit fixes that by using
whatever aliases were created (which coincidentally aren't
quoted) to perform the lookup.