Cached ForeignObject.(local/foreign/reverse)_related_fields properties.
@@ -616,21 +616,19 @@ class ForeignObject(RelatedField):
related_fields.append((from_field, to_field))
return related_fields
- @property
+ @cached_property
def related_fields(self):
- if not hasattr(self, '_related_fields'):
- self._related_fields = self.resolve_related_fields()
- return self._related_fields
+ return self.resolve_related_fields()
- @property
+ @cached_property
def reverse_related_fields(self):
return [(rhs_field, lhs_field) for lhs_field, rhs_field in self.related_fields]
- @property
+ @cached_property
def local_related_fields(self):
return tuple(lhs_field for lhs_field, rhs_field in self.related_fields)
- @property
+ @cached_property
def foreign_related_fields(self):
return tuple(rhs_field for lhs_field, rhs_field in self.related_fields if rhs_field)
