#14408: Admin Error when subclassing ContentType for generic Relations
--------------------------+-------------------------------------------------
 Reporter:  MS            |       Owner:  nobody    
   Status:  new           |   Milestone:            
Component:  Contrib apps  |     Version:  1.2       
 Keywords:                |       Stage:  Unreviewed
Has_patch:  0             |  
--------------------------+-------------------------------------------------
 If you subclass the ContentType with a proxy model, for example to use
 other ordering or change some other Meta options, you will get an error in
 the Admin interface, when using GenericTabularInline.

 The problem is line 357 in
 
http://code.djangoproject.com/browser/django/trunk/django/contrib/contenttypes/generic.py,
 where the test is with equal but should be subcalss instead.

 Example in models:
 {{{
 from django.db import models
 from django.contrib.contenttypes import generic
 from django.contrib.contenttypes.models import ContentType as CT

 class ContentType(CT):

     class Meta:
         proxy = True
         ordering = ('app_label', 'model')

 class ModelWithGeneric(models.Model):
     content_type = models.ForeignKey(ContentType)
     object_id = models.PositiveIntegerField()
     contentObject = generic.GenericForeignKey('content_type', 'object_id')

 class ObjectWithGeneric(models.Model):
     media = generic.GenericRelation(ModelWithGeneric,
 content_type_field='content_type', object_id_field='object_id')
 }}}

 Example in Admin:
 {{{
 from django.contrib.contenttypes import generic
 from django.contrib import admin

 from apps.models import *

 class GenericInlineAdmin(generic.GenericTabularInline):
     model = ModelWithGeneric


 class ObjectAdmin(admin.ModelAdmin):
     inlines = (
         GenericInlineAdmin,
     )
 admin.site.register(ObjectWithGeneric, ObjectAdmin)

 }}}

 Error is: fk_name '<django.db.models.fields.related.ForeignKey object at
 0x0319A1F0>' is not a ForeignKey to ContentType

-- 
Ticket URL: <http://code.djangoproject.com/ticket/14408>
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-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to