diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index 88bc0b5c15b..f269d9e17fb 100644 --- a/django/db/models/fields/related.py +++ b/django/db/models/fields/related.py @@ -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)