You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class Model:
field1 = MonitorField(monitor=field2)
field2 = SomeField()
class ProxyModel:
class Meta:
proxy = True
Environment
Django Model Utils version: 3.0.0
Django version: 1.10.7
Python version: 2.7
Other libraries used, if any: ...
Code examples
our "sollution"
class CustomMonitorField(MonitorField):
def pre_save(self, model_instance, add):
value = now()
previous_instance = model_instance.__class__.objects.get(pk=model_instance.pk)
previous = self.get_monitored_value(previous_instance)
current = self.get_monitored_value(model_instance)
if previous != current:
if self.when is None or current in self.when:
setattr(model_instance, self.attname, value)
self._save_initial(model_instance.__class__, model_instance)
return super(MonitorField, self).pre_save(model_instance, add)
The text was updated successfully, but these errors were encountered:
Problem
Environment
Code examples
our "sollution"
The text was updated successfully, but these errors were encountered: