save to db and return saved object

def save_to_db(model_text_id, parsed_values):
        """save to db and return saved object"""
        Model = apps.get_model(model_text_id)

        # normalise values and separate to m2m, simple
        simple_fields = {}
        many2many_fields = {}
        for field, value in parsed_values.items():
            if (Model._meta.get_field(
                    field).get_internal_type() == 'ManyToManyField'):
                many2many_fields[field] = value
            elif (Model._meta.get_field(
                    field).get_internal_type() == 'DateTimeField'):
                simple_fields[field] = time_parser.parse(value)

            else:
                simple_fields[field] = value

        # ToDo: add unique identify parameter to field
        # ToDo: allow unique identify m2m field
        model, created = Model.objects.get_or_create(**simple_fields)

        for field, value in many2many_fields.items():
            setattr(model, field, value)
        model.save()

        return model