﻿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
9546	GenericForeignKey + model inheritance: uses wrong content type	miracle2k	nobody	"{{{
class Link(models.Model):
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = generic.GenericForeignKey(ct_field=""content_type"", fk_field=""object_id"")

class Base(models.Model):
    links = GenericRelation(Link)
class Sub(Base): pass
}}}

{{{
>>> link = Link()
>>> link.content_type = sub_instance
>>> link.save()   # saves with ""sub"" content type 

>>> sub_instance.links.all()   # queries with ""base"" content type 
[]
>>> sub_instance.base_ptr.links.all()  # queries with ""base"" content type 
[]
}}}

The expected result would contain the Link object just created, presumably in both cases, but at least in the first. Either GenericForeignKey should use the parent class content type, or GenericRelation uses the content type of the model it is accessed through.

There may be additional complexities involved when using multiple model inheritance, but I can't quite wrap my head around those so far."		closed	Contrib apps	1.0		fixed		Nicola Larosa	Accepted	0	0	0	0	0	0
