>> How can I tell which model fields have been modified (this is, the 
>> difference between the Model instance and the data originally retrieved 
>> from the database) from inside the model's save() method?
> 
> You can always retrieve the model by it's primary key from the db, and
> then compare self to it.  Something like:
> 
> def save(stuff_and_junk):
>     existing_instance = self.__class__.objects.get(id=self.id)
>     if existing_instance.attribute != self.attribute:
>         print 'Holy Crap!'
>     super(self.__class__, self).save(stuff_and_junk)

Remembering, of course, that get() can throw an exception if 
you're creating a new object...

-tim



--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to