MCPcopy
hub / github.com/django/django / m2m_convert

Function m2m_convert

django/core/serializers/base.py:361–369  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

359 if hasattr(model._default_manager, "get_by_natural_key"):
360
361 def m2m_convert(value):
362 if hasattr(value, "__iter__") and not isinstance(value, str):
363 return (
364 model._default_manager.db_manager(using)
365 .get_by_natural_key(*value)
366 .pk
367 )
368 else:
369 return model._meta.pk.to_python(value)
370
371 else:
372

Callers 2

deserialize_m2m_valuesFunction · 0.85

Calls 3

db_managerMethod · 0.80
get_by_natural_keyMethod · 0.45
to_pythonMethod · 0.45

Tested by

no test coverage detected