code: def install_middleware(self):
          
          from django.conf import settings
  
          # If MIDDLEWARE is set, update that, with handling of tuple vs array forms
          if getattr(settings, "MIDDLEWARE", None) is not None:
              if isinstance(settings.MIDDLEWARE, tuple):
                  settings.MIDDLEWARE = (
                      ("scout_apm.django.middleware.MiddlewareTimingMiddleware",)
                      + settings.MIDDLEWARE
                      + ("scout_apm.django.middleware.ViewTimingMiddleware",)
                  )
              else:
                  settings.MIDDLEWARE.insert(
                      0, "scout_apm.django.middleware.MiddlewareTimingMiddleware"
                  )
                  settings.MIDDLEWARE.append(
                      "scout_apm.django.middleware.ViewTimingMiddleware"
                  )
  
          # Otherwise, we're doing old style middleware, do the same thing with
          # the same handling of tuple vs array forms
          else:
              if isinstance(settings.MIDDLEWARE_CLASSES, tuple):
                  settings.MIDDLEWARE_CLASSES = (
                      ("scout_apm.django.middleware.OldStyleMiddlewareTimingMiddleware",)
                      + settings.MIDDLEWARE_CLASSES
                      + ("scout_apm.django.middleware.OldStyleViewMiddleware",)
                  )
              else:
                  settings.MIDDLEWARE_CLASSES.insert(
                      0, "scout_apm.django.middleware.OldStyleMiddlewareTimingMiddleware"
                  )
                  settings.MIDDLEWARE_CLASSES.append(
                      "scout_apm.django.middleware.OldStyleViewMiddleware"
                  )
docs: Attempts to insert the ScoutApm middleware as the first middleware
          (first on incoming requests, last on outgoing responses).