class Field: (source)
Known subclasses: rest_framework.fields.BooleanField
, rest_framework.fields.CharField
, rest_framework.fields.ChoiceField
, rest_framework.fields.DateField
, rest_framework.fields.DateTimeField
, rest_framework.fields.DecimalField
, rest_framework.fields.DictField
, rest_framework.fields.DurationField
, rest_framework.fields.FileField
, rest_framework.fields.FloatField
, rest_framework.fields.HiddenField
, rest_framework.fields.IntegerField
, rest_framework.fields.JSONField
, rest_framework.fields.ListField
, rest_framework.fields.ModelField
, rest_framework.fields.ReadOnlyField
, rest_framework.fields.SerializerMethodField
, rest_framework.fields.TimeField
, rest_framework.fields.UUIDField
, rest_framework.relations.ManyRelatedField
, rest_framework.relations.RelatedField
, rest_framework.serializers.BaseSerializer
, rest_framework.fields._UnvalidatedField
Undocumented
Method | __deepcopy__ |
When cloning fields we instantiate using the arguments it was originally created with, rather than copying the complete state. |
Method | __init__ |
Undocumented |
Method | __new__ |
When a field is instantiated, we store the arguments that were used, so that we can present a helpful representation of the object. |
Method | __repr__ |
Fields are represented using their initial calling arguments. This allows us to create descriptive representations for serializer instances that show all the declared fields on the serializer. |
Method | bind |
Initializes the field name and parent for the field instance. Called when a field is added to the parent serializer instance. |
Method | fail |
A helper method that simply raises a validation error. |
Method | get |
Given the *outgoing* object instance, return the primitive value that should be used for this field. |
Method | get |
Return the default value to use when validating data if no input is provided for this field. |
Method | get |
Return a value to use when the field is being returned as a primitive value, without any object instance. |
Method | get |
Undocumented |
Method | get |
Given the *incoming* primitive data, return the value for this field that should be validated and transformed to a native value. |
Method | run |
Validate a simple representation and return the internal value. |
Method | run |
Test the given value against all the validators on the field, and either raise a `ValidationError` or simply return. |
Method | to |
Transform the *incoming* primitive data into a native value. |
Method | to |
Transform the *outgoing* native value into primitive data. |
Method | validate |
Validate empty values, and either: |
Method | validators |
Undocumented |
Class Variable | default |
Undocumented |
Class Variable | default |
Undocumented |
Instance Variable | allow |
Undocumented |
Instance Variable | default |
Undocumented |
Instance Variable | default |
Undocumented |
Instance Variable | error |
Undocumented |
Instance Variable | field |
Undocumented |
Instance Variable | help |
Undocumented |
Instance Variable | initial |
Undocumented |
Instance Variable | label |
Undocumented |
Instance Variable | parent |
Undocumented |
Instance Variable | read |
Undocumented |
Instance Variable | required |
Undocumented |
Instance Variable | source |
Undocumented |
Instance Variable | source |
Undocumented |
Instance Variable | style |
Undocumented |
Instance Variable | write |
Undocumented |
Property | context |
Returns the context as passed to the root serializer on initialization. |
Property | root |
Returns the top-level serializer for this field. |
Property | validators |
Undocumented |
Instance Variable | _creation |
Undocumented |
Instance Variable | _validators |
Undocumented |
When cloning fields we instantiate using the arguments it was originally created with, rather than copying the complete state.
rest_framework.fields.CharField
, rest_framework.fields.ChoiceField
, rest_framework.fields.DateField
, rest_framework.fields.DateTimeField
, rest_framework.fields.DecimalField
, rest_framework.fields.DictField
, rest_framework.fields.DurationField
, rest_framework.fields.FileField
, rest_framework.fields.FloatField
, rest_framework.fields.HiddenField
, rest_framework.fields.IntegerField
, rest_framework.fields.JSONField
, rest_framework.fields.ListField
, rest_framework.fields.ModelField
, rest_framework.fields.ReadOnlyField
, rest_framework.fields.SerializerMethodField
, rest_framework.fields.TimeField
, rest_framework.fields.UUIDField
, rest_framework.relations.ManyRelatedField
, rest_framework.relations.RelatedField
, rest_framework.serializers.BaseSerializer
, rest_framework.fields._UnvalidatedField
Undocumented
When a field is instantiated, we store the arguments that were used, so that we can present a helpful representation of the object.
Fields are represented using their initial calling arguments. This allows us to create descriptive representations for serializer instances that show all the declared fields on the serializer.
rest_framework.fields.SerializerMethodField
Initializes the field name and parent for the field instance. Called when a field is added to the parent serializer instance.
rest_framework.fields.ModelField
, rest_framework.relations.ManyRelatedField
, rest_framework.relations.RelatedField
Given the *outgoing* object instance, return the primitive value that should be used for this field.
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.
Return a value to use when the field is being returned as a primitive value, without any object instance.
rest_framework.fields.DictField
, rest_framework.fields.HiddenField
, rest_framework.fields.JSONField
, rest_framework.fields.ListField
, rest_framework.fields.MultipleChoiceField
, rest_framework.relations.ManyRelatedField
, rest_framework.serializers.ListSerializer
, rest_framework.serializers.Serializer
Given the *incoming* primitive data, return the value for this field that should be validated and transformed to a native value.
rest_framework.fields.CharField
, rest_framework.relations.RelatedField
, rest_framework.serializers.ListSerializer
, rest_framework.serializers.Serializer
Validate a simple representation and return the internal value. The provided data may be `empty` if no representation was included in the input. May raise `SkipField` if the field should not be included in the validated data.
rest_framework.serializers.Serializer
Test the given value against all the validators on the field, and either raise a `ValidationError` or simply return.
rest_framework.fields.BooleanField
, rest_framework.fields.CharField
, rest_framework.fields.ChoiceField
, rest_framework.fields.DateField
, rest_framework.fields.DateTimeField
, rest_framework.fields.DecimalField
, rest_framework.fields.DictField
, rest_framework.fields.DurationField
, rest_framework.fields.FileField
, rest_framework.fields.FloatField
, rest_framework.fields.HiddenField
, rest_framework.fields.IntegerField
, rest_framework.fields.JSONField
, rest_framework.fields.ListField
, rest_framework.fields.ModelField
, rest_framework.fields.TimeField
, rest_framework.fields.UUIDField
, rest_framework.relations.HyperlinkedRelatedField
, rest_framework.relations.ManyRelatedField
, rest_framework.relations.PrimaryKeyRelatedField
, rest_framework.relations.SlugRelatedField
, rest_framework.serializers.BaseSerializer
, rest_framework.fields._UnvalidatedField
Transform the *incoming* primitive data into a native value.
rest_framework.fields.BooleanField
, rest_framework.fields.CharField
, rest_framework.fields.ChoiceField
, rest_framework.fields.DateField
, rest_framework.fields.DateTimeField
, rest_framework.fields.DecimalField
, rest_framework.fields.DictField
, rest_framework.fields.DurationField
, rest_framework.fields.FileField
, rest_framework.fields.FloatField
, rest_framework.fields.IntegerField
, rest_framework.fields.JSONField
, rest_framework.fields.ListField
, rest_framework.fields.ModelField
, rest_framework.fields.ReadOnlyField
, rest_framework.fields.SerializerMethodField
, rest_framework.fields.TimeField
, rest_framework.fields.UUIDField
, rest_framework.relations.HyperlinkedRelatedField
, rest_framework.relations.ManyRelatedField
, rest_framework.relations.PrimaryKeyRelatedField
, rest_framework.relations.SlugRelatedField
, rest_framework.relations.StringRelatedField
, rest_framework.serializers.BaseSerializer
, rest_framework.fields._UnvalidatedField
Transform the *outgoing* native value into primitive data.
rest_framework.fields.DecimalField
Validate empty values, and either: * Raise `ValidationError`, indicating invalid data. * Raise `SkipField`, indicating that the field should be ignored. * Return (True, data), indicating an empty value that should be returned without any further validation being applied. * Return (False, data), indicating a non-empty value, that should have validation applied as normal.
rest_framework.fields.BooleanField
, rest_framework.fields.CharField
, rest_framework.fields.ChoiceField
, rest_framework.fields.DateField
, rest_framework.fields.DateTimeField
, rest_framework.fields.DecimalField
, rest_framework.fields.DictField
, rest_framework.fields.DurationField
, rest_framework.fields.FileField
, rest_framework.fields.FloatField
, rest_framework.fields.IntegerField
, rest_framework.fields.JSONField
, rest_framework.fields.ListField
, rest_framework.fields.ModelField
, rest_framework.fields.TimeField
, rest_framework.fields.UUIDField
, rest_framework.relations.HyperlinkedRelatedField
, rest_framework.relations.ManyRelatedField
, rest_framework.relations.PrimaryKeyRelatedField
, rest_framework.relations.SlugRelatedField
, rest_framework.serializers.ListSerializer
, rest_framework.serializers.Serializer
Undocumented
rest_framework.fields.BooleanField
, rest_framework.fields.MultipleChoiceField
, rest_framework.relations.ManyRelatedField
Undocumented