class Serializer(BaseSerializer): (source)
Known subclasses: rest_framework.authtoken.serializers.AuthTokenSerializer
, rest_framework.serializers.ModelSerializer
Undocumented
Method | __getitem__ |
Undocumented |
Method | __iter__ |
Undocumented |
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 | get |
Returns a dictionary of {field_name: field_instance}. |
Method | get |
Return a value to use when the field is being returned as a primitive value, without any object instance. |
Method | get |
Returns a list of validator callables. |
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 |
We override the default `run_validation`, because the validation performed by validators and the `.validate()` method should be coerced into an error dictionary with a 'non_fields_error' key. |
Method | run |
Add read_only fields with defaults to value before running validators. |
Method | to |
Dict of native values <- Dict of primitive datatypes. |
Method | to |
Object instance -> Dict of primitive datatypes. |
Method | validate |
Undocumented |
Class Variable | default |
Undocumented |
Property | data |
Undocumented |
Property | errors |
Undocumented |
Property | fields |
A dictionary of {field_name: field_instance}. |
Method | _read |
Undocumented |
Property | _readable |
Undocumented |
Property | _writable |
Undocumented |
Inherited from BaseSerializer
:
Class Method | many |
This method implements the creation of a `ListSerializer` parent class when `many=True` is used. You can customize it if you need to control which keyword arguments are passed to the parent, and which are passed to the child. |
Method | __class |
Undocumented |
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 | create |
Undocumented |
Method | is |
Undocumented |
Method | save |
Undocumented |
Method | update |
Undocumented |
Instance Variable | initial |
Undocumented |
Instance Variable | instance |
Undocumented |
Instance Variable | partial |
Undocumented |
Property | validated |
Undocumented |
Instance Variable | _context |
Undocumented |
Instance Variable | _validated |
Undocumented |
Inherited from Field
(via BaseSerializer
):
Method | __deepcopy__ |
When cloning fields we instantiate using the arguments it was originally created with, rather than copying the complete state. |
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 | validate |
Validate empty values, and either: |
Method | validators |
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 |
rest_framework.fields.Field.__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.
rest_framework.serializers.ModelSerializer
Returns a dictionary of {field_name: field_instance}.
rest_framework.fields.Field.get_initial
Return a value to use when the field is being returned as a primitive value, without any object instance.
rest_framework.fields.Field.get_value
Given the *incoming* primitive data, return the value for this field that should be validated and transformed to a native value.
We override the default `run_validation`, because the validation performed by validators and the `.validate()` method should be coerced into an error dictionary with a 'non_fields_error' key.