Created
March 21, 2020 03:39
-
-
Save ychennay/b5a58acfc0edefae6570b51dd42f87f9 to your computer and use it in GitHub Desktop.
ForeignKeyDeferredAttribute example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ForeignKeyDeferredAttribute(DeferredAttribute): | |
def __set__(self, instance, value): | |
if instance.__dict__.get(self.field.attname) != value and self.field.is_cached(instance): | |
self.field.delete_cached_value(instance) | |
instance.__dict__[self.field.attname] = value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment