python - what are most frequently used real-time examples of Django custom middleware? It would be great if a code snippet is also shared -


what used real-time examples of django custom middleware? great if code snippet shared.

a common piece of middleware forcing users use https. here's snippet:

from django.conf import settings django.http import httpresponsepermanentredirect   class sslifymiddleware(object):     """force requests use https. if http request, we'll     force redirect https."""      def process_request(self, request):         secure_url = url.replace('http://', 'https://')         return httpresponsepermanentredirect(secure_url) 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -