Opened 21 months ago

Closed 21 months ago

Last modified 21 months 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 Changed 21 months ago by Mariusz Felisiak

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 Changed 21 months ago by 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?

Last edited 21 months ago by Jej (previous) (diff)

comment:3 Changed 21 months ago by Jej

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

comment:4 in reply to:  2 Changed 21 months ago by Mariusz Felisiak

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 Changed 21 months ago by Jej

Ok. Thanks for the explanation of the underlaying.

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