def find_ordering_name(self, name, opts, alias=None, default_order='ASC',
            already_seen=None):
        name, order = get_order_dir(name, default_order)
        pieces = name.split(LOOKUP_SEP)
        field, cols, alias, joins, opts = self._setup_joins(pieces, opts, alias)

        # If we get to this point and the field is a relation to another model,
        # append the default ordering for that model.
        if field.rel and len(joins) > 1 and opts.ordering:
            # Firstly, avoid infinite loops.
            if not already_seen:
                already_seen = set()
            join_tuple = tuple([self.query.alias_map[j].table_name for j in joins])
            if join_tuple in already_seen:
                raise FieldError('Infinite loop caused by ordering.')
            already_seen.add(join_tuple)

            results = []
            for item in opts.ordering:
                results.extend(self.find_ordering_name(item, opts, alias,
                        order, already_seen))
            return results
        cols, alias = self._final_join_removal(cols, alias)
        return [(alias, cols, order)]
Returns the table alias (the name might be ambiguous, the alias will
dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/Django-1.6.10/django/db/models/sql/compiler.py/SQLCompiler.find_ordering_name