﻿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
8483	Admin interface does not check for incompatible generic relations	Stefan Moluf	Ramiro Morales	"{{{
# myapp.models.py
from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic

class User (models.Model):
    username = models.CharField(max_length=50, primary_key=True)
    birthdate = models.DateField()

class PhoneNumber:
    phone_number = PhoneNumberField()
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = generic.GenericForeignKey()
}}}

{{{
# myapp.admin.py
from django.contrib import admin
from myapp.models import *
from django.contrib.contenttypes import generic

class PhoneNumberInline (admin.TabularInline):
    model = PhoneNumber

class UserAdmin (admin.ModelAdmin):
    inlines = [
        PhoneNumberInline,
    ]
admin.site.register(User, UserAdmin)
}}}

In the above example, a PhoneNumber cannot be associated with a User because the PhoneNumber stores object_id as a PositiveIntegerField, whereas the primary key of User is a CharField. However, the admin interface does not check for this and throws a ValueError exception when it attempts to give PhoneNumber.object_id (an integer) the value of User.username (a string).

It seems to me this should be a ConfigurationError."		closed	contrib.admin	dev		wontfix	pycamp2009		Accepted	1	0	0	0	0	0
