# relations.relation\_proxy ## RelationProxy Objects ```python class RelationProxy(list) ``` Proxy of the Relation that is a list with special methods. #### related\_field\_name ```python | @property | related_field_name() -> str ``` On first access calculates the name of the related field, later stored in _related_field_name property. **Returns**: `(str)`: name of the related field #### \_\_getattribute\_\_ ```python | __getattribute__(item: str) -> Any ``` Since some QuerySetProxy methods overwrite builtin list methods we catch calls to them and delegate it to QuerySetProxy instead. **Arguments**: - `item (str)`: name of attribute **Returns**: `(Any)`: value of attribute #### \_\_getattr\_\_ ```python | __getattr__(item: str) -> Any ``` Delegates calls for non existing attributes to QuerySetProxy. **Arguments**: - `item (str)`: name of attribute/method **Returns**: `(method)`: method from QuerySetProxy if exists #### \_initialize\_queryset ```python | _initialize_queryset() -> None ``` Initializes the QuerySetProxy if not yet initialized. #### \_check\_if\_queryset\_is\_initialized ```python | _check_if_queryset_is_initialized() -> bool ``` Checks if the QuerySetProxy is already set and ready. **Returns**: `(bool)`: result of the check #### \_check\_if\_model\_saved ```python | _check_if_model_saved() -> None ``` Verifies if the parent model of the relation has been already saved. Otherwise QuerySetProxy cannot filter by parent primary key. #### \_set\_queryset ```python | _set_queryset() -> "QuerySet" ``` Creates new QuerySet with relation model and pre filters it with currents parent model primary key, so all queries by definition are already related to the parent model only, without need for user to filter them. **Returns**: `(QuerySet)`: initialized QuerySet #### remove ```python | async remove(item: "Model", keep_reversed: bool = True) -> None ``` Removes the related from relation with parent. Through models are automatically deleted for m2m relations. For reverse FK relations keep_reversed flag marks if the reversed models should be kept or deleted from the database too (False means that models will be deleted, and not only removed from relation). **Arguments**: - `item (Model)`: child to remove from relation - `keep_reversed (bool)`: flag if the reversed model should be kept or deleted too #### add ```python | async add(item: "Model", **kwargs: Any) -> None ``` Adds child model to relation. For ManyToMany relations through instance is automatically created. **Arguments**: - `kwargs (Any)`: dict of additional keyword arguments for through instance - `item (Model)`: child to add to relation