MCPcopy
hub / github.com/django/django / serializable_value

Method serializable_value

django/db/models/base.py:816–831  ·  view source on GitHub ↗

Return the value of the field name for this instance. If the field is a foreign key, return the id value instead of the object. If there's no Field object with this name on the model, return the model attribute's value. Used to serialize a field's value (in

(self, field_name)

Source from the content-addressed store, hash-verified

814 )
815
816 def serializable_value(self, field_name):
817 """
818 Return the value of the field name for this instance. If the field is
819 a foreign key, return the id value instead of the object. If there's
820 no Field object with this name on the model, return the model
821 attribute's value.
822
823 Used to serialize a field's value (in the serializer, or form output,
824 for example). Normally, you would just access the attribute directly
825 and not use this method.
826 """
827 try:
828 field = self._meta.get_field(field_name)
829 except FieldDoesNotExist:
830 return getattr(self, field_name)
831 return getattr(self, field.attname)
832
833 def save(
834 self,

Callers 5

response_addMethod · 0.80
response_changeMethod · 0.80
_delete_viewMethod · 0.80
items_for_resultFunction · 0.80
prepare_valueMethod · 0.80

Calls 1

get_fieldMethod · 0.45

Tested by

no test coverage detected