Skip to main content

convert_python_value_to_field

Function convert_python_value_to_field 

Source
pub fn convert_python_value_to_field(
    py_value: &Bound<'_, PyAny>,
    descriptor: &FieldDescriptor,
) -> Result<FieldValue, DjangoError>
Expand description

Converts a Python object from a Django model instance into a FieldValue.

Inspects the FieldDescriptor to determine the expected type, then attempts extraction. Returns FieldValue::Null for Python None, and DjangoError for type mismatches that cannot be resolved.

§Arguments

  • py_value - The raw Python object from getattr(instance, field_name).
  • descriptor - The field descriptor specifying the expected type.