code: def _rewrite_col(self, col):
          
          if isinstance(col, Col):
              new_name = rewrite_lookup_key(self.model, col.target.name)
              if col.target.name != new_name:
                  new_field = self.model._meta.get_field(new_name)
                  if col.target is col.source:
                      col.source = new_field
                  col.target = new_field
          elif hasattr(col, 'col'):
              self._rewrite_col(col.col)
          elif hasattr(col, 'lhs'):
              self._rewrite_col(col.lhs)
docs: Django >= 1.7 column name rewriting