Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#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 Mariusz Felisiak, 3 years ago

Resolution: invalid
Status: newclosed

I don't think there is much Django can do in such cases. It's an issue in your code.

comment:2 by Jej, 3 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?

Version 1, edited 3 years ago by Jej (previous) (next) (diff)

comment:3 by Jej, 3 years ago

Summary: makemigrations reports "No changes detected" if a property exists with the same namemakemigrations reports "No changes detected" if a property exists with the same field name

in reply to:  2 comment:4 by Mariusz Felisiak, 3 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.

comment:5 by Jej, 3 years ago

Ok. Thanks for the explanation of the underlaying.

Note: See TracTickets for help on using tickets.
Back to Top