#NEWLINE# def index_del_instance( sender , instance , **kwargs ) : #NEWLINE# #INDENT# '\n    Like index_add_instance but deletes the instance from the index.\n\n    Should be called by the post_delete signal.\n    ' #NEWLINE# try : #NEWLINE# #INDENT# sender . get_search_index_string #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# with index . get_or_create_index ( ) . writer ( ) as writer : #NEWLINE# #INDENT# writer . delete_by_term ( 'id_collection' , combine_id_and_collection ( instance ) )