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

Method get_value

rest_framework/fields.py:407–429  ·  view source on GitHub ↗

Given the *incoming* primitive data, return the value for this field that should be validated and transformed to a native value.

(self, dictionary)

Source from the content-addressed store, hash-verified

405 return self.initial
406
407 def get_value(self, dictionary):
408 """
409 Given the *incoming* primitive data, return the value for this field
410 that should be validated and transformed to a native value.
411 """
412 if html.is_html_input(dictionary):
413 # HTML forms will represent empty fields as '', and cannot
414 # represent None or False values directly.
415 if self.field_name not in dictionary:
416 if getattr(self.root, 'partial', False):
417 return empty
418 return self.default_empty_html
419 ret = dictionary[self.field_name]
420 if ret == '' and self.allow_null:
421 # If the field is blank, and null is a valid value then
422 # determine if we should use null instead.
423 return '' if getattr(self, 'allow_blank', False) else None
424 elif ret == '' and not self.required:
425 # If the field is blank, and emptiness is valid then
426 # determine if we should use emptiness instead.
427 return '' if getattr(self, 'allow_blank', False) else empty
428 return ret
429 return dictionary.get(self.field_name, empty)
430
431 def get_attribute(self, instance):
432 """

Calls 1

getMethod · 0.45