Opened 11 years ago

Closed 9 years ago

#633 closed defect (invalid)

Model _post_load method (or similiar for a field?)

Reported by: wojtek@… Owned by: adrian
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: UI/UX:


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 Changed 9 years ago by Gary Wilson <gary.wilson@…>

  • Triage Stage changed from Unreviewed to Design decision needed

comment:2 Changed 9 years ago by mtredinnick

  • Resolution set to invalid
  • Status changed from new to closed

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