'We have a bit of extra checking around this in order to provide
descriptive messages when something goes wrong, but this method is
essentially just:
return ExampleModel.objects.create(**validated_data)
If there are many to many fields present on the instance then they
cannot be set until the model is instantiated, in which case the
implementation is like so:
example_relationship = validated_data.pop(\'example_relationship\')
instance = ExampleModel.objects.create(**validated_data)
instance.example_relationship = example_relationship
return instance
The default implementation also does not handle nested relationships.
If you want to support writable nested relationships you\'ll need
to write an explicit `.create()` method.'

def create(self, validated_data):

    raise_errors_on_nested_writes(u'create', self, validated_data)
    ModelClass = self.Meta.model
    info = model_meta.get_field_info(ModelClass)
    many_to_many = {}
    for (field_name, relation_info) in info.relations.items():
        if (relation_info.to_many and (field_name in validated_data)):
            many_to_many[field_name] = validated_data.pop(field_name)
    try:
        instance = ModelClass.objects.create(**validated_data)
    except TypeError:
        tb = traceback.format_exc()
        msg = (u'Got    a    `TypeError`    when    calling    `%s.objects.create()`.    This    may    be    because    you    have    a    writable    field    on    the    serializer    class    that    is    not    a    valid    argument    to    `%s.objects.create()`.    You    may    need    to    make    the    field    read-only,    or    override    the    %s.create()    method    to    handle    this    correctly.\nOriginal    exception    was:\n    %s' % (ModelClass.__name__, ModelClass.__name__, self.__class__.__name__, tb))
        raise TypeError(msg)
    if many_to_many:
        for (field_name, value) in many_to_many.items():
            set_many(instance, field_name, value)
    return instance
