﻿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
10108	Two classes with a common superclass have multiple ForeignKeys from one to the other if the one has a single Foreign Key to the other.	mail@…	nobody	"Given three classes as follows:
{{{
class Item(models.Model):

class Computer(Item):

class CPU(Item):
    computer = models.ForeignKey(Computer)
}}}

When inlining CPU into Computer in the admin interface the following exception is raised:
{{{
<class 'comprec.inventory.models.CPU'> has more than 1 ForeignKey to <class 'comprec.inventory.models.Computer'>
}}}

This is caused by the OneToOne field created implicitly by the inheritance as mentioned on http://docs.djangoproject.com/en/dev/ref/models/fields/#onetoonefield conflicting with the defined ForeignKey on the model. This leads to unexpected behaviour as it is expected that the single defined ForeignKey field is used in the admin form. The error appears to be caused by the _get_foreign_key function in forms/models.py which uses isinstance(f, ForeignKey) on the fields on the model with the ForeignKey to find which field to use but this returns true on OneToOne fields, not just ForeignKey fields.

A traceback of the error is available at http://dpaste.com/112033/."		new	Core (Other)	dev			foreign key, inheritance, ForeignKey, OneToOne		Unreviewed	0	0	0	0	0	0
