Opened 19 years ago

Closed 18 years ago

#633 closed defect (invalid)

Model _post_load method (or similiar for a field?)

Reported by: wojtek@… 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 Gary Wilson <gary.wilson@…>, 18 years ago

Triage Stage: UnreviewedDesign decision needed

comment:2 by Malcolm Tredinnick, 18 years ago

Resolution: invalid
Status: newclosed

This can be done by writing your own __init__ method on the model and just remember to call models.Model.__init__(....) first in your own function. Once the __init__ from the !Model class returns, the database fields will have been loaded and populated.

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