#16739 closed Bug (duplicate)
Model field clash not detected beyond parent
Reported by: | Leo Shklovskii | Owned by: | |
---|---|---|---|
Component: | Core (System checks) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When a local field in a class has the same name as a field in the superclass Django throws a FieldError when it spins up. However, it only checks the immediate parent, it doesn't go further up the tree so the following code doesn't trigger a FieldError (which it should):
class A(models.Model): foo = models.IntegerField() class B(A): pass class C(B): foo = models.IntegerField()
Attachments (1)
Change History (8)
comment:1 by , 13 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 12 years ago
Type: | Uncategorized → Bug |
---|
comment:4 by , 10 years ago
Component: | Database layer (models, ORM) → Core (System checks) |
---|---|
Owner: | removed |
Status: | assigned → new |
Summary: | field clash not detected beyond parent → Model field clash not detected beyond parent |
Confirmed this is still an issue with the attached test for Django's test suite.
by , 10 years ago
Attachment: | 16739-test.diff added |
---|
comment:5 by , 10 years ago
I think this ticket can be marked as fixed or duplicate now, fixed here #24249.
comment:6 by , 10 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Right, thanks for checking (Tim's test is now passing well).
Note:
See TracTickets
for help on using tickets.
I confirm the bug. With this code in a
models.py
:Expected result of
./manage.py validate
:Actual result: no error.
I tried to write a test case in
invalid_models
, but that didn't work because the name clash creates an exception, not a validation error.