Opened 19 years ago
Closed 18 years ago
#633 closed defect (invalid)
Model _post_load method (or similiar for a field?)
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Design decision needed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
It would be nice to be able to do some operations right after an object is loaded from the DB. One example would be having some field which has to be pickled/unpickled when storing it in the DB.
This could be implemented either by adding a model _post_load method or by adding such a method to a field.
Any other workarounds which would work with current Django version that I'm missing?
Change History (2)
comment:1 by , 18 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:2 by , 18 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
This can be done by writing your own
__init__
method on the model and just remember to callmodels.Model.__init__(....)
first in your own function. Once the__init__
from the !Model class returns, the database fields will have been loaded and populated.