MCPcopy
hub / github.com/django/django / related_objects

Method related_objects

django/db/models/options.py:618–638  ·  view source on GitHub ↗

Return all related objects pointing to the current model. The related objects can come from a one-to-one, one-to-many, or many-to-many field relation type. Private API intended only to be used by Django itself; get_fields() combined with filtering of field p

(self)

Source from the content-addressed store, hash-verified

616
617 @cached_property
618 def related_objects(self):
619 """
620 Return all related objects pointing to the current model. The related
621 objects can come from a one-to-one, one-to-many, or many-to-many field
622 relation type.
623
624 Private API intended only to be used by Django itself; get_fields()
625 combined with filtering of field properties is the public API for
626 obtaining this field list.
627 """
628 all_related_fields = self._get_fields(
629 forward=False, reverse=True, include_hidden=True
630 )
631 return make_immutable_fields_list(
632 "related_objects",
633 (
634 obj
635 for obj in all_related_fields
636 if not obj.hidden or obj.field.many_to_many
637 ),
638 )
639
640 @cached_property
641 def _forward_fields_map(self):

Callers

nothing calls this directly

Calls 2

_get_fieldsMethod · 0.95

Tested by

no test coverage detected