#32731 closed Uncategorized (invalid)
makemigrations reports "No changes detected" if a property exists with the same field name
Reported by: | Jej | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | 3.2 |
Severity: | Normal | Keywords: | annoying |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I turned around few time trying to add a new field in my model (FK). makemigrations reported "No changes detected". I dropped the database and after migrations files cleanup, the field was still not created. The reason was I had a @property method with the same name in the model. Logically I wanted to replace this calculated field by a db field, but didn't think about to check it was here already as a property.
I would prefer that django report the problem when two properties are conflicting or may conflict in case the field is created.
Change History (5)
comment:1 by , 4 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
follow-up: 4 comment:2 by , 4 years ago
Of course it's an issue in my code. But django warn about a lot of issues in user code. Why not this one and just silently does nothing?!! Why a field in the model would be ignored without notice?
comment:3 by , 4 years ago
Summary: | makemigrations reports "No changes detected" if a property exists with the same name → makemigrations reports "No changes detected" if a property exists with the same field name |
---|
comment:4 by , 4 years ago
Replying to Jej:
Django warn about a lot of issues in user code. Why not this one and just silently does nothing? Why a field in the model would be ignored without notice?
Because you override it in your own code, so it's not a model field anymore. I'm happy to review a patch if you know how to check easily that a property overrides a model field in the same class.
I don't think there is much Django can do in such cases. It's an issue in your code.