def save( self ): if self._get_pk_val(): old = MyModel.objects.get( pk = self._get_pk_val() ) if self.field != old.field: print "Values do not match" super( MyModel, self ).save()
On 31 янв, 10:54, Julien <[EMAIL PROTECTED]> wrote: > Hi there, > > I'd like to override the save() method and within it I'd like to test > if a value has changed, that is, if that value as stored in the object > (in memory) is different from what is actually stored in database. > Something like: > > class A: > stuff = models.blabla > > def save(self): > if self.stuff != > magic_function_that_tells_what_is_in_database_for('stuff') > do_this() > super(A, self).save() > > Any idea? > > Thanks! > > Julien --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---