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 ove
> 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.
Another approach is using __getattr__ to monitor changes. It saves you a
qu
Yep, I should have thought of that. Cheers!
On Jan 31, 7:13 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote:
> > def save(self):
> > if self.stuff !=
> > magic_function_that_tells_what_is_in_database_for('stuff')
> > do_this()
> > super(A, self).save()
>
> This 'magic function' is
>
> def save(self):
> if self.stuff !=
> magic_function_that_tells_what_is_in_database_for('stuff')
> do_this()
> super(A, self).save()
This 'magic function' is
self.__class__.objects.get(id=self.id).stuff
if self.stuff != self.__class__.objects.get(id=self.id).stuff:
do_this()
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 sel
5 matches
Mail list logo