Created
March 22, 2020 04:00
-
-
Save ychennay/07a2c04f27fc974f0cf02b8f78b573d0 to your computer and use it in GitHub Desktop.
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
data = instance.__dict__ # get the specific Student instance's symbol table | |
field_name = self.field.attname # pull out the field name (first name, in our case) | |
if data.get(field_name, self) is self: | |
# Let's see if the field is part of the parent chain. If so we | |
# might be able to reuse the already loaded value. Refs #18343. | |
val = self._check_parent_chain(instance) # check if this value is already pulled down from the db upstream | |
if val is None: | |
instance.refresh_from_db(fields=[field_name]) | |
val = getattr(instance, field_name) | |
data[field_name] = val # set the student instance __dict__ key for future attribute lookups! | |
return data[field_name] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment