﻿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
29574	"Unable to create model instance after changing an abstract model to non-abstract due to ""foreign key mismatch"" error"	josephbiko		"Django Foreign key's do not track the models DB when the model is inherited from abstract class.

Steps to reproduce:

create models:""

{{{
class A(models.Model):
    field = models.IntegerField()
    
    class Meta:
        abstract = True

class B(A):
    field2 = models.IntegerField()

class C(models.Model):
    fk = models.ForeignKey(B,on_delete=models.CASCADE)
}}}

migrate

change the models (by removeing the meta )to:
{{{
class A(models.Model):
    field = models.IntegerField()


class B(A):
    field2 = models.IntegerField()

class C(models.Model):
    fk = models.ForeignKey(B,on_delete=models.CASCADE)
}}}

run migrations.

Now add an object of class B in the admin.

resulting error:
""foreign key mismatch - ""models_c"" referencing ""models_b""""

"	Bug	new	Migrations	2.1	Normal			josephbiko	Accepted	0	0	0	0	0	0
