reverse_field_path
Create a reversed field path.
E.g. Given (Order, "user__groups"),
return (Group, "user__order").
Final field must be a related model, not a data field.
def reverse_field_path(
model: Model,
path: string
) - > tuple
Create a reversed field path. E.g. Given (Order, "user__groups"), return (Group, "user__order"). Final field must be a related model, not a data field.
Parameters
| Name | Type | Description |
|---|---|---|
| model | Model | The starting Django model class from which the field path originates |
| path | string | A double-underscore separated string representing the relationship traversal path to be inverted |
Returns
| Type | Description |
|---|---|
tuple | A tuple containing the target model class and the string representation of the reversed lookup path |