def get_distinct(self):
        """
        Returns a quoted list of fields to use in DISTINCT ON part of the query.

        Note that this method can alter the tables in the query, and thus it
        must be called before get_from_clause().
        """
        qn = self.quote_name_unless_alias
        qn2 = self.connection.ops.quote_name
        result = []
        opts = self.query.get_meta()

        for name in self.query.distinct_fields:
            parts = name.split(LOOKUP_SEP)
            field, cols, alias, _, _ = self._setup_joins(parts, opts, None)
            cols, alias = self._final_join_removal(cols, alias)
            for col in cols:
                result.append("%s.%s" % (qn(alias), qn2(col)))
        return result
dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/Django-1.6.10/django/db/models/sql/compiler.py/SQLCompiler.get_distinct/original