I create my own django response object editing middleware to act as a censor. I would like to find a way to do a kind of search and replace, replacing all instances of a word with the one that I choose.
I created my middleware object, added it to the MIDDLEWARE_CLASSES settings MIDDLEWARE_CLASSES and configured it to handle the response. But so far I have found methods for adding / editing cookies, setting / deleting dictionary elements, or writing to the end of html:
class CensorWare(object): def process_response(self, request, response): """ Directly edit response object here, searching for and replacing terms in the html. """ return response
Thanks in advance.
python html django
Richard Jelte Jun 10 2018-12-12T00: 00Z
source share