def __setattr__(self, attr, value):
if attr == '<STR_LIT>' or attr in self.get_unique_fields():<EOL><INDENT>try:<EOL><INDENT>current = self.__dict__[attr]<EOL><DEDENT>except (AttributeError, KeyError, ObjectDoesNotExist):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>previously_set = getattr(self, '<STR_LIT>' % attr, False)<EOL>if current != value and not previously_set:<EOL><INDENT>setattr(self, '<STR_LIT>' % attr, current)<EOL><DEDENT><DEDENT><DEDENT>super(Orderable, self).__setattr__(attr, value)<EOL>
Cache original value of `sort_order` when a change is made to it.

Also cache values of other unique together fields.

Greatly inspired by http://code.google.com/p/django-audit/