diff options
| author | sarthakmeh <sarthakmeh03@gmail.com> | 2015-08-25 23:07:32 +0530 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-08-25 16:16:54 -0400 |
| commit | 4bc00defd0cf4de3baf90cad43da62e531987459 (patch) | |
| tree | 59dba839620536d6a49733a02adbb25bf357d444 /tests/invalid_models_tests | |
| parent | 7efdd40407838dc3c922e0e62e9b4eefabe7de01 (diff) | |
Fixed #14217 -- Added validation for field name collision when using model inheritance.
Diffstat (limited to 'tests/invalid_models_tests')
| -rw-r--r-- | tests/invalid_models_tests/test_models.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py index a27357a1a6..a93789003f 100644 --- a/tests/invalid_models_tests/test_models.py +++ b/tests/invalid_models_tests/test_models.py @@ -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() |
