(self, instance_or_query)
Delete an ``instance`` or a ``query``.

        Adds ``instance_or_query`` to this :class:`Session` list
        of data to be deleted. If the session is not in a
        :ref:`transactional state <transactional-state>`, this operation
        commits changes to the backend server immediately.

        :parameter instance_or_query: a :class:`Model` instance or
            a :class:`Query`.
Delete an ``instance`` or a ``query``.
Delete an instance or a query .
def delete(self, instance_or_query):
        '''Delete an ``instance`` or a ``query``.

        Adds ``instance_or_query`` to this :class:`Session` list
        of data to be deleted. If the session is not in a
        :ref:`transactional state <transactional-state>`, this operation
        commits changes to the backend server immediately.

        :parameter instance_or_query: a :class:`Model` instance or
            a :class:`Query`.
        '''
        sm = self.model(instance_or_query)
        # not an instance of a Model. Assume it is a query.
        if is_query(instance_or_query):
            if instance_or_query.session is not self:
                raise ValueError('Adding a query generated by another session')
            sm._delete_query.append(instance_or_query)
        else:
            instance_or_query = sm.delete(instance_or_query, self)
        if not self.transaction:
            transaction = self.begin()
            return transaction.commit(
                lambda: transaction.deleted.get(sm._meta))
        else:
            return instance_or_query
def delete ( self , instance_or_query ) : sm = self . model ( instance_or_query ) # not an instance of a Model. Assume it is a query. if is_query ( instance_or_query ) : if instance_or_query . session is not self : raise ValueError ( 'Adding a query generated by another session' ) sm . _delete_query . append ( instance_or_query ) else : instance_or_query = sm . delete ( instance_or_query , self ) if not self . transaction : transaction = self . begin ( ) return transaction . commit ( lambda : transaction . deleted . get ( sm . _meta ) ) else : return instance_or_query