Re: compare old and new model field value

2008-11-11 Thread Rock
Take a look at http://code.google.com/p/django-reversion/ which may be more than what you need, but certainly fills the bill for your general use case. On Nov 10, 1:03 pm, Tim <[EMAIL PROTECTED]> wrote: > Basically, I want to be able to do something if the value of a field > changes in a model.

Re: compare old and new model field value

2008-11-11 Thread Alex Koshelev
Why not simple fetch `old version` of object from database and compare its fields. For example: def save(self, *args, **kwargs): if self._get_pk_val(): old = self.__class__.objects.get(pk=self._get_pk_val() for field in self.__class__._meta.fields: old_value =

compare old and new model field value

2008-11-10 Thread Tim
Basically, I want to be able to do something if the value of a field changes in a model. c = Category.objects.get(pk=1) c.name = "New Name" c.save() At any point (when the model is saved, when the value is set, etc.) is it possible to compare the old and new value? The first thought that popped