Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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