def save(self, internal=False, meta=None, index_fields=None):
for f in self.on_save:<EOL><INDENT>f(self)<EOL><DEDENT>if not (internal or self._pre_save_hook_called):<EOL><INDENT>self._pre_save_hook_called = True<EOL>self.pre_save()<EOL><DEDENT>if not self.deleted:<EOL><INDENT>self._handle_uniqueness()<EOL><DEDENT>if not self.exist:<EOL><INDENT>self.pre_creation()<EOL><DEDENT>old_data = self._data.copy()<EOL>if self.just_created is None:<EOL><INDENT>self.setattrs(just_created=not self.exist)<EOL><DEDENT>if self._just_created is None:<EOL><INDENT>self.setattrs(_just_created=self.just_created)<EOL><DEDENT>self.objects.save_model(self, meta_data=meta, index_fields=index_fields)<EOL>self._handle_changed_fields(old_data)<EOL>self._process_relations(internal)<EOL>if not (internal or self._post_save_hook_called):<EOL><INDENT>self._post_save_hook_called = True<EOL>self.post_save()<EOL>if self._just_created:<EOL><INDENT>self.setattrs(just_created=self._just_created,<EOL>_just_created=False)<EOL>self.post_creation()<EOL><DEDENT><DEDENT>self._pre_save_hook_called = False<EOL>self._post_save_hook_called = False<EOL>if not internal:<EOL><INDENT>self._initial_data = self.clean_value()<EOL><DEDENT>return self<EOL>
Save's object to DB.

Do not override this method, use pre_save and post_save methods.

Args:
    internal (bool): True if called within model.
        Used to prevent unneccessary calls to pre_save and
        post_save methods.
    meta (dict): JSON serializable meta data for logging of save operation.
        {'lorem': 'ipsum', 'dolar': 5}
    index_fields (list): Tuple list for indexing keys in riak (with 'bin' or 'int').
        bin is used for string fields, int is used for integer fields.
        [('lorem','bin'),('dolar','int')]

Returns:
     Saved model instance.