[docs]def__call__(self,request):"""Process the response and strip extra newlines from HTML."""response=self.get_response(request)is_html=(response["Content-Type"]=="text/html"orresponse["Content-Type"].startswith("text/html;")if"Content-Type"inresponseelseFalse)# noqa: E501 pylint: disable=line-too-longifis_htmlandsettings.DEBUG:response.content=re.sub(r"\n(\s*)\n","\n",response.content.decode())response.content=re.sub(r"^(\s*)\n","",response.content.decode())returnresponse
[docs]classAdminSelectizeLoadingIndicatorMiddleware:"""Automatically add a loading placeholder for Selectize inputs in admin templates. This is probably not a good practice, but it really needs to be done server-side for the loading indicators to show up instantly. """