mirror of https://github.com/django/django.git
parent
316cc34d04
commit
0c0240aba8
|
@ -59,6 +59,36 @@ class AbstractInheritanceTests(SimpleTestCase):
|
|||
),
|
||||
])
|
||||
|
||||
def test_target_field_may_be_pushed_down(self):
|
||||
"""
|
||||
Where the Child model needs to inherit a field from a different base
|
||||
than that given by depth-first resolution, the target field can be
|
||||
**pushed down** by being re-declared.
|
||||
"""
|
||||
|
||||
class Root(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
class ParentA(Root):
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
class ParentB(Root):
|
||||
name = models.IntegerField()
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
class Child(ParentA, ParentB):
|
||||
name = models.IntegerField()
|
||||
|
||||
self.assertEqual(Child.check(), [])
|
||||
inherited_field = Child._meta.get_field('name')
|
||||
self.assertTrue(isinstance(inherited_field, models.IntegerField))
|
||||
|
||||
def test_multiple_inheritance_cannot_shadow_concrete_inherited_field(self):
|
||||
class ConcreteParent(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
|
|
Loading…
Reference in New Issue