1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #14217 -- Added validation for field name collision when using model inheritance.

This commit is contained in:
sarthakmeh
2015-08-25 23:07:32 +05:30
committed by Tim Graham
parent 7efdd40407
commit 4bc00defd0
3 changed files with 27 additions and 1 deletions

View File

@@ -436,6 +436,25 @@ class FieldNamesTests(IsolatedModelsTestCase):
class ShadowingFieldsTests(IsolatedModelsTestCase):
def test_field_name_clash_with_child_accessor(self):
class Parent(models.Model):
pass
class Child(Parent):
child = models.CharField(max_length=100)
errors = Child.check()
expected = [
Error(
"The field 'child' clashes with the field "
"'child' from model 'invalid_models_tests.parent'.",
hint=None,
obj=Child._meta.get_field('child'),
id='models.E006',
)
]
self.assertEqual(errors, expected)
def test_multiinheritance_clash(self):
class Mother(models.Model):
clash = models.IntegerField()