Loading django/db/models/base.py +6 −6 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ class ModelBase(type): # All the fields of any type declared on this model new_fields = new_class._meta.local_fields + \ new_class._meta.many_to_many + \ new_class._meta.local_many_to_many + \ new_class._meta.virtual_fields field_names = set([f.name for f in new_fields]) Loading tests/regressiontests/model_inheritance_regress/models.py +12 −1 Original line number Diff line number Diff line Loading @@ -71,6 +71,12 @@ class Article(models.Model): class ArticleWithAuthor(Article): author = models.CharField(max_length=100) class M2MBase(models.Model): articles = models.ManyToManyField(Article) class M2MChild(M2MBase): name = models.CharField(max_length=50) __test__ = {'API_TESTS':""" # Regression for #7350, #7202 # Check that when you create a Parent object with a specific reference to an Loading Loading @@ -231,4 +237,9 @@ Traceback (most recent call last): ... DoesNotExist: ArticleWithAuthor matching query does not exist. # Regression test for #8825: Make sure all inherited fields (esp. m2m fields, in # this case) appear on the child class. >>> M2MChild.objects.filter(articles__isnull=False) [] """} Loading
django/db/models/base.py +6 −6 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ class ModelBase(type): # All the fields of any type declared on this model new_fields = new_class._meta.local_fields + \ new_class._meta.many_to_many + \ new_class._meta.local_many_to_many + \ new_class._meta.virtual_fields field_names = set([f.name for f in new_fields]) Loading
tests/regressiontests/model_inheritance_regress/models.py +12 −1 Original line number Diff line number Diff line Loading @@ -71,6 +71,12 @@ class Article(models.Model): class ArticleWithAuthor(Article): author = models.CharField(max_length=100) class M2MBase(models.Model): articles = models.ManyToManyField(Article) class M2MChild(M2MBase): name = models.CharField(max_length=50) __test__ = {'API_TESTS':""" # Regression for #7350, #7202 # Check that when you create a Parent object with a specific reference to an Loading Loading @@ -231,4 +237,9 @@ Traceback (most recent call last): ... DoesNotExist: ArticleWithAuthor matching query does not exist. # Regression test for #8825: Make sure all inherited fields (esp. m2m fields, in # this case) appear on the child class. >>> M2MChild.objects.filter(articles__isnull=False) [] """}