#9546: GenericForeignKey + model inheritance: uses wrong content type
--------------------------+-------------------------------------------------
 Reporter:  miracle2k     |       Owner:  nobody    
   Status:  new           |   Milestone:            
Component:  Contrib apps  |     Version:  1.0       
 Keywords:                |       Stage:  Unreviewed
Has_patch:  0             |  
--------------------------+-------------------------------------------------
 {{{
 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.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/9546>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to