﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
16316	Error with GenericRelation applied to a subclass	jordanreiter@…	nobody	"I noticed this when using the django-threadedcomments app and trying to add a `GenericRelation` pointing to the `ThreadedComment` model. I would assume this holds true for any model that subclasses a model with generic foreign keys.

{{{
class Discussion(models.Model):
    title = models.CharField(max_length=100, help_text='Enter a descriptive title for this discussion.')
    content = models.TextField(null=True, blank=True)
    date = models.DateTimeField()
    comments = generic.GenericRelation(ThreadedComment)
}}}

And then


{{{
>>> Discussion.objects.filter(comments__isnull=False)
Traceback (most recent call last):
  File ""<console>"", line 1, in <module>
  File ""/path/to/django/db/models/query.py"", line 69, in __repr__
    data = list(self[:REPR_OUTPUT_SIZE + 1])
  File ""/path/to/django/db/models/query.py"", line 84, in __len__
    self._result_cache.extend(self._iter)
  File ""/path/to/django/db/models/query.py"", line 273, in iterator
    for row in compiler.results_iter():
  File ""/path/to/django/db/models/sql/compiler.py"", line 680, in results_iter
    for rows in self.execute_sql(MULTI):
  File ""/path/to/django/db/models/sql/compiler.py"", line 735, in execute_sql
    cursor.execute(sql, params)
  File ""/path/to/django/db/backends/mysql/base.py"", line 86, in execute
    return self.cursor.execute(query, args)
  File ""/srv/python-environments/academicexperts/lib/python2.7/site-packages/MySQLdb/cursors.py"", line 174, in execute
    self.errorhandler(self, exc, value)
  File ""/srv/python-environments/academicexperts/lib/python2.7/site-packages/MySQLdb/connections.py"", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
OperationalError: (1054, ""Unknown column 'threadedcomments_comment.object_id' in 'on clause'"")
>>> 

}}}

"	Bug	closed	Database layer (models, ORM)	1.3	Normal	duplicate			Unreviewed	0	0	0	0	0	0
