0

I am trying to define custom model field class in Django and I need to perform some action (delete related data) when the value changes (i.e. when the related object is no more needed and needs to be destroyed).

But there seems to be no easy way to detect value change from within the field. It gets only the new value. Is the old one just silently lost without any possibility to destroy object it represents? How to detect the change then?

Notabene: I know it is possible from within the model, but what I'm going to do is to write a field which would need no changes in models it is used in. I've seen django-dirtyfields, but it still does it only at the level of model, not at the level of field (or I don't understand it fully).

jaboja
  • 2,178
  • 1
  • 21
  • 35

0 Answers0