#34719 closed Bug (duplicate)

modelBase.add_to_class is ineffective when called in __init_subclass__ of an abstract Model

Reported by: piscvau Owned by: nobody
Component: Database layer (models, ORM) Version: 4.1
Severity: Normal Keywords: dynamic model modification
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Using an abstract model which is also an abstract class.
In the subclass, I need to modify a field. This is done in the init_subclass method, by creating a field and adding it to the model with ModelBase.add_to_class.
The field disappears from the class.

Doing exactly the same on a model which is not an abstract class works fine.

see unittest file to reproduce this bug.

Attachments (1)

tests_abcmodel_bug.py (4.9 KB ) - added by piscvau 17 months ago.
unittest test file to reproduce

Download all attachments as: .zip

Change History (2)

by piscvau, 17 months ago

Attachment: tests_abcmodel_bug.py added

unittest test file to reproduce

comment:1 by Simon Charette, 17 months ago

Resolution: duplicate
Status: newclosed

Duplicate of #34555.

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