MCPcopy Index your code
hub / github.com/encode/django-rest-framework / get_default

Method get_default

rest_framework/fields.py:472–490  ·  view source on GitHub ↗

Return the default value to use when validating data if no input is provided for this field. If a default has not been set for this field then this will simply raise `SkipField`, indicating that no value should be set in the validated data for this field.

(self)

Source from the content-addressed store, hash-verified

470 raise type(exc)(msg)
471
472 def get_default(self):
473 """
474 Return the default value to use when validating data if no input
475 is provided for this field.
476
477 If a default has not been set for this field then this will simply
478 raise `SkipField`, indicating that no value should be set in the
479 validated data for this field.
480 """
481 if self.default is empty or getattr(self.root, 'partial', False):
482 # No default, or this is a partial update.
483 raise SkipField()
484 if callable(self.default):
485 if getattr(self.default, 'requires_context', False):
486 return self.default(self)
487 else:
488 return self.default()
489
490 return self.default
491
492 def validate_empty_values(self, data):
493 """

Callers 4

get_attributeMethod · 0.95
validate_empty_valuesMethod · 0.95
_read_only_defaultsMethod · 0.80
get_attributeMethod · 0.80

Calls 2

SkipFieldClass · 0.85
defaultMethod · 0.80

Tested by

no test coverage detected