I have recently discovered that Django admin is generating errors when trying to sort a table on certain fields: in particular, those fields that are ForeignKey linked to a separate table, each of which has a 'name' field. Selecting any of these columns for a sort generates this error:
OperationalError at /admin/myapp/mytable/ (1060, "Duplicate column name 'name'") A full stack trace is shown below. I am working with MySQL 5.5 and Django 1.6.3. Has anyone else encountered this error? Is this a known bug and/or is there a workaround? Thanks Derek Stack Trace: Traceback: File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 139. response = response.render() File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/template/response.py" in render 105. self.content = self.rendered_content File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/template/response.py" in rendered_content 82. content = template.render(context) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/template/base.py" in render 140. return self._render(context) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/template/base.py" in _render 134. return self.nodelist.render(context) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/template/base.py" in render 840. bit = self.render_node(node, context) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/template/base.py" in render_node 854. return node.render(context) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render 123. return compiled_parent._render(context) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/template/base.py" in _render 134. return self.nodelist.render(context) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/template/base.py" in render 840. bit = self.render_node(node, context) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/template/base.py" in render_node 854. return node.render(context) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render 123. return compiled_parent._render(context) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/template/base.py" in _render 134. return self.nodelist.render(context) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/template/base.py" in render 840. bit = self.render_node(node, context) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/template/base.py" in render_node 854. return node.render(context) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render 62. result = block.nodelist.render(context) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/template/base.py" in render 840. bit = self.render_node(node, context) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/template/base.py" in render_node 854. return node.render(context) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render 62. result = block.nodelist.render(context) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/template/base.py" in render 840. bit = self.render_node(node, context) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/template/base.py" in render_node 854. return node.render(context) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/template/base.py" in render 1196. _dict = func(*resolved_args, **resolved_kwargs) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/contrib/admin/templatetags/admin_list.py" in date_hierarchy 312. last=models.Max(field_name)) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/db/models/query.py" in aggregate 278. return query.get_aggregation(using=self.db) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/db/models/sql/query.py" in get_aggregation 356. result = query.get_compiler(using).execute_sql(SINGLE) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql 786. cursor.execute(sql, params) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/db/backends/util.py" in execute 69. return super(CursorDebugWrapper, self).execute(sql, params) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/db/backends/util.py" in execute 53. return self.cursor.execute(sql, params) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/db/utils.py" in __exit__ 99. six.reraise(dj_exc_type, dj_exc_value, traceback) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/db/backends/util.py" in execute 53. return self.cursor.execute(sql, params) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py" in execute 124. return self.cursor.execute(query, args) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/MySQLdb/cursors.py" in execute 201. self.errorhandler(self, exc, value) File "/home/derek/.virtualenvs/demo/local/lib/python2.7/site-packages/MySQLdb/connections.py" in defaulterrorhandler 36. raise errorclass, errorvalue -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF1Wu3OiP%2BBC2WW5u6GjWukGu%3D%2BuZVBy4e5NniBQQctYaRW7YQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.