MCPcopy
hub / github.com/django/django / _value_from_field

Method _value_from_field

django/core/serializers/python.py:42–49  ·  view source on GitHub ↗
(self, obj, field)

Source from the content-addressed store, hash-verified

40 return data
41
42 def _value_from_field(self, obj, field):
43 if isinstance(field, CompositePrimaryKey):
44 return [self._value_from_field(obj, f) for f in field]
45 value = field.value_from_object(obj)
46 # Protected types (i.e., primitives like None, numbers, dates,
47 # and Decimals) are passed through as is. All other values are
48 # converted to string first.
49 return value if is_protected_type(value) else field.value_to_string(obj)
50
51 def handle_field(self, obj, field):
52 self._current[field.name] = self._value_from_field(obj, field)

Callers 4

get_dump_objectMethod · 0.95
handle_fieldMethod · 0.95
handle_fk_fieldMethod · 0.95
m2m_valueMethod · 0.95

Calls 3

is_protected_typeFunction · 0.90
value_from_objectMethod · 0.45
value_to_stringMethod · 0.45

Tested by

no test coverage detected