Added order_by because I was getting the following error:

DatabaseError: SELECT DISTINCT ON expressions must match initial ORDER BY expressions
LINE 1: SELECT DISTINCT ON ("db_lookup"."name") "db_lookup"."name", ...