@contextmanager
def patch_search_fields(model, new_search_fields):
 old_search_fields = model.search_fields
 model.search_fields = new_search_fields
 (yield)
 model.search_fields = old_search_fields

@ contextmanager def patch_search_fields ( model , new_search_fields ) : old_search_fields = model . search_fields model . search_fields = new_search_fields ( yield ) model . search_fields = old_search_fields
a context manager to allow testing of different search_fields configurations without permanently changing the models search_fields .