'Perform an atomic update of the document in the database and reload
the document object using updated version.
Returns True if the document has been updated or False if the document
in the database doesn\'t match the query.
.. note:: All unsaved changes that have been made to the document are
rejected if the method returns True.
:param query: the update will be performed only if the document in the
database matches the query
:param update: Django-style update keyword arguments'

def modify(self, query=None, **update):

    if (query is None):
        query = {}
    if (self.pk is None):
        raise InvalidDocumentError('The    document    does    not    have    a    primary    key.')
    id_field = self._meta['id_field']
    query = (query.copy() if isinstance(query, dict) else query.to_query(self))
    if (id_field not in query):
        query[id_field] = self.pk
    elif (query[id_field] != self.pk):
        raise InvalidQueryError('Invalid    document    modify    query:    it    must    modify    only    this    document.')
    updated = self._qs(**query).modify(new=True, **update)
    if (updated is None):
        return False
    for field in self._fields_ordered:
        setattr(self, field, self._reload(field, updated[field]))
    self._changed_fields = updated._changed_fields
    self._created = False
    return True
