﻿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
14408	Admin Error when subclassing ContentType for generic Relations	MS	nobody	"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"	Bug	closed	contrib.admin	1.2	Normal	invalid			Accepted	0	0	0	0	0	0
