from django.http import HttpResponse


class PingMiddleware:
    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request):
        return self.ping(request) or self.get_response(request)

    def ping(self, request):
        """
        Returns that the server is alive.
        """
        if request.method == "GET":
            if request.path == "/ping.json":
                return HttpResponse("OK")

from django.http import HttpResponse
from django.utils.deprecation import MiddlewareMixin


class PingMiddleware(MiddlewareMixin):
    def process_request(self, request):
        if request.method == "GET":
            if request.path == "/ping.json":
                return self.ping(request)
        pass

    def ping(self, request):
        """
        Returns that the server is alive.
        """
        return HttpResponse("OK")

--- 
+++ 
@@ -1,16 +1,17 @@
 from django.http import HttpResponse
-from django.utils.deprecation import MiddlewareMixin
 
 
-class PingMiddleware(MiddlewareMixin):
-    def process_request(self, request):
-        if request.method == "GET":
-            if request.path == "/ping.json":
-                return self.ping(request)
-        pass
+class PingMiddleware:
+    def __init__(self, get_response):
+        self.get_response = get_response
+
+    def __call__(self, request):
+        return self.ping(request) or self.get_response(request)
 
     def ping(self, request):
         """
         Returns that the server is alive.
         """
-        return HttpResponse("OK")
+        if request.method == "GET":
+            if request.path == "/ping.json":
+                return HttpResponse("OK")
Remove use of django.utils.deprecation.MiddlewareMixin for PingMiddleware and  upgrade Middleware to latest spec
