Opened 16 months ago
Closed 16 months ago
#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)
Note:
See TracTickets
for help on using tickets.
unittest test file to reproduce