lookup_field
Retrieves a field, its attribute, and its value from a given object or model admin by resolving the provided name, which can be a field name, property, method, or lookup path.
def lookup_field(
name: str | callable,
obj: object,
model_admin: ModelAdmin | None = None
) - > tuple
Resolves a field name or callable into its corresponding field object, attribute, and value for a given model instance.
Parameters
| Name | Type | Description |
|---|---|---|
| name | `str | callable` |
| obj | object | The model instance from which the data is being retrieved. |
| model_admin | `ModelAdmin | None` = None |
Returns
| Type | Description |
|---|---|
tuple | A triple containing (field_object, attribute, value), where field_object is the Django field instance, attribute is the resolved callable or property, and value is the actual data retrieved. |