Просмотр исходного кода

HUE-9650 [Django Upgrade] Old-style middleware using settings.MIDDLEWARE_CLASSES is deprecated

ayush.goyal 4 лет назад
Родитель
Сommit
d24d6db999

+ 2 - 1
apps/useradmin/src/useradmin/middleware.py

@@ -28,6 +28,7 @@ from django.contrib.sessions.models import Session
 from django.db import DatabaseError
 from django.db.models import Q
 from django.utils.translation import ugettext as _
+from django.utils.deprecation import MiddlewareMixin
 
 from desktop.auth.views import dt_logout
 from desktop.conf import AUTH, LDAP, SESSION
@@ -75,7 +76,7 @@ class LdapSynchronizationMiddleware(object):
       request.session.modified = True
 
 
-class LastActivityMiddleware(object):
+class LastActivityMiddleware(MiddlewareMixin):
   """
   Middleware to track the last activity of a user and automatically log out the user after a specified period of inactivity
   """

+ 0 - 28
desktop/core/ext-py/BabelDjango-0.2.2/COPYING

@@ -1,28 +0,0 @@
-Copyright (C) 2007 Edgewall Software
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
- 1. Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
-    notice, this list of conditions and the following disclaimer in
-    the documentation and/or other materials provided with the
-    distribution.
- 3. The name of the author may not be used to endorse or promote
-    products derived from this software without specific prior
-    written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
-OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ 0 - 10
desktop/core/ext-py/BabelDjango-0.2.2/PKG-INFO

@@ -1,10 +0,0 @@
-Metadata-Version: 1.0
-Name: BabelDjango
-Version: 0.2.2
-Summary: Utilities for using Babel in Django
-Home-page: http://babel.edgewall.org/wiki/BabelDjango
-Author: Edgewall Software
-Author-email: python-babel@googlegroups.com
-License: BSD
-Description: UNKNOWN
-Platform: UNKNOWN

+ 0 - 13
desktop/core/ext-py/BabelDjango-0.2.2/README.txt

@@ -1,13 +0,0 @@
-Tools for using Babel with Django
-=================================
-
-This package contains various utilities for integration of Babel into the
-Django web framework:
-
- * A message extraction plugin for Django templates.
- * A middleware class that adds the Babel `Locale` object to requests.
- * A set of template tags for date and number formatting.
-
-For more information please visit the wiki page for this package:
-
-  <http://babel.edgewall.org/wiki/BabelDjango>

+ 0 - 12
desktop/core/ext-py/BabelDjango-0.2.2/babeldjango/__init__.py

@@ -1,12 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2007 Edgewall Software
-# All rights reserved.
-#
-# This software is licensed as described in the file COPYING, which
-# you should have received as part of this distribution. The terms
-# are also available at http://babel.edgewall.org/wiki/License.
-#
-# This software consists of voluntary contributions made by many
-# individuals. For the exact contribution history, see the revision
-# history and logs, available at http://babel.edgewall.org/log/.

+ 0 - 110
desktop/core/ext-py/BabelDjango-0.2.2/babeldjango/extract.py

@@ -1,110 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2007 Edgewall Software
-# All rights reserved.
-#
-# This software is licensed as described in the file COPYING, which
-# you should have received as part of this distribution. The terms
-# are also available at http://babel.edgewall.org/wiki/License.
-#
-# This software consists of voluntary contributions made by many
-# individuals. For the exact contribution history, see the revision
-# history and logs, available at http://babel.edgewall.org/log/.
-
-from babel.core import *
-
-from django.conf import settings
-settings.configure(USE_I18N=True)
-from django.template import Lexer, TOKEN_TEXT, TOKEN_VAR, TOKEN_BLOCK
-from django.utils.translation.trans_real import inline_re, block_re, \
-                                                endblock_re, plural_re, \
-                                                constant_re
-
-def extract_django(fileobj, keywords, comment_tags, options):
-    """Extract messages from Django template files.
-
-    :param fileobj: the file-like object the messages should be extracted from
-    :param keywords: a list of keywords (i.e. function names) that should
-                     be recognized as translation functions
-    :param comment_tags: a list of translator tags to search for and
-                         include in the results
-    :param options: a dictionary of additional options (optional)
-    :return: an iterator over ``(lineno, funcname, message, comments)``
-             tuples
-    :rtype: ``iterator``
-    """
-    intrans = False
-    inplural = False
-    singular = []
-    plural = []
-    lineno = 1
-    for t in Lexer(fileobj.read(), None).tokenize():
-        lineno += t.contents.count('\n')
-        if intrans:
-            if t.token_type == TOKEN_BLOCK:
-                endbmatch = endblock_re.match(t.contents)
-                pluralmatch = plural_re.match(t.contents)
-                if endbmatch:
-                    if inplural:
-                        yield lineno, 'ngettext', (unicode(''.join(singular)),
-                                                   unicode(''.join(plural))), []
-                    else:
-                        yield lineno, None, unicode(''.join(singular)), []
-                    intrans = False
-                    inplural = False
-                    singular = []
-                    plural = []
-                elif pluralmatch:
-                    inplural = True
-                else:
-                    raise SyntaxError('Translation blocks must not include '
-                                      'other block tags: %s' % t.contents)
-            elif t.token_type == TOKEN_VAR:
-                if inplural:
-                    plural.append('%%(%s)s' % t.contents)
-                else:
-                    singular.append('%%(%s)s' % t.contents)
-            elif t.token_type == TOKEN_TEXT:
-                if inplural:
-                    plural.append(t.contents)
-                else:
-                    singular.append(t.contents)
-        else:
-            if t.token_type == TOKEN_BLOCK:
-                imatch = inline_re.match(t.contents)
-                bmatch = block_re.match(t.contents)
-                cmatches = constant_re.findall(t.contents)
-                if imatch:
-                    g = imatch.group(1)
-                    if g[0] == '"':
-                        g = g.strip('"')
-                    elif g[0] == "'":
-                        g = g.strip("'")
-                    yield lineno, None, unicode(g), []
-                elif bmatch:
-                    for fmatch in constant_re.findall(t.contents):
-                        yield lineno, None, unicode(fmatch), []
-                    intrans = True
-                    inplural = False
-                    singular = []
-                    plural = []
-                elif cmatches:
-                    for cmatch in cmatches:
-                        yield lineno, None, unicode(cmatch), []
-            elif t.token_type == TOKEN_VAR:
-                parts = t.contents.split('|')
-                cmatch = constant_re.match(parts[0])
-                if cmatch:
-                    yield lineno, None, unicode(cmatch.group(1)), []
-                for p in parts[1:]:
-                    if p.find(':_(') >= 0:
-                        p1 = p.split(':',1)[1]
-                        if p1[0] == '_':
-                            p1 = p1[1:]
-                        if p1[0] == '(':
-                            p1 = p1.strip('()')
-                        if p1[0] == "'":
-                            p1 = p1.strip("'")
-                        elif p1[0] == '"':
-                            p1 = p1.strip('"')
-                        yield lineno, None, unicode(p1), []

+ 0 - 46
desktop/core/ext-py/BabelDjango-0.2.2/babeldjango/middleware.py

@@ -1,46 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2007 Edgewall Software
-# All rights reserved.
-#
-# This software is licensed as described in the file COPYING, which
-# you should have received as part of this distribution. The terms
-# are also available at http://babel.edgewall.org/wiki/License.
-#
-# This software consists of voluntary contributions made by many
-# individuals. For the exact contribution history, see the revision
-# history and logs, available at http://babel.edgewall.org/log/.
-
-from babel import Locale, UnknownLocaleError
-from django.conf import settings
-try:
-    from threading import local
-except ImportError:
-    from django.utils._threading_local import local
-
-__all__ = ['get_current_locale', 'LocaleMiddleware']
-
-_thread_locals = local()
-
-def get_current_locale():
-    """Get current locale data outside views.
-
-    See http://babel.edgewall.org/wiki/ApiDocs/babel.core for Locale
-    objects documentation
-    """
-    return getattr(_thread_locals, 'locale', None)
-
-
-class LocaleMiddleware(object):
-    """Simple Django middleware that makes available a Babel `Locale` object
-    via the `request.locale` attribute.
-    """
-
-    def process_request(self, request):
-        try:
-            code = getattr(request, 'LANGUAGE_CODE', settings.LANGUAGE_CODE)
-            locale = Locale.parse(code, sep='-')
-        except (ValueError, UnknownLocaleError):
-            pass
-        else:
-            _thread_locals.locale = request.locale = locale

+ 0 - 12
desktop/core/ext-py/BabelDjango-0.2.2/babeldjango/templatetags/__init__.py

@@ -1,12 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2007 Edgewall Software
-# All rights reserved.
-#
-# This software is licensed as described in the file COPYING, which
-# you should have received as part of this distribution. The terms
-# are also available at http://babel.edgewall.org/wiki/License.
-#
-# This software consists of voluntary contributions made by many
-# individuals. For the exact contribution history, see the revision
-# history and logs, available at http://babel.edgewall.org/log/.

+ 0 - 70
desktop/core/ext-py/BabelDjango-0.2.2/babeldjango/templatetags/babel.py

@@ -1,70 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2007 Edgewall Software
-# All rights reserved.
-#
-# This software is licensed as described in the file COPYING, which
-# you should have received as part of this distribution. The terms
-# are also available at http://babel.edgewall.org/wiki/License.
-#
-# This software consists of voluntary contributions made by many
-# individuals. For the exact contribution history, see the revision
-# history and logs, available at http://babel.edgewall.org/log/.
-
-from django.conf import settings
-from django.template import Library
-from django.utils.translation import to_locale
-try:
-    from pytz import timezone
-except ImportError:
-    timezone = None
-
-from babeldjango.middleware import get_current_locale
-
-babel = __import__('babel', {}, {}, ['core', 'support'])
-Format = babel.support.Format
-Locale = babel.core.Locale
-
-register = Library()
-
-def _get_format():
-    locale = get_current_locale()
-    if not locale:
-        locale = Locale.parse(to_locale(settings.LANGUAGE_CODE))
-    if timezone:
-        tzinfo = timezone(settings.TIME_ZONE)
-    else:
-        tzinfo = None
-    return Format(locale, tzinfo)
-
-def datefmt(date=None, format='medium'):
-    return _get_format().date(date, format=format)
-datefmt = register.filter(datefmt)
-
-def datetimefmt(datetime=None, format='medium'):
-    return _get_format().datetime(datetime, format=format)
-datetimefmt = register.filter(datetimefmt)
-
-def timefmt(time=None, format='medium'):
-    return _get_format().time(time, format=format)
-timefmt = register.filter(timefmt)
-
-def numberfmt(number):
-    return _get_format().number(number)
-numberfmt = register.filter(numberfmt)
-
-def decimalfmt(number, format=None):
-    return _get_format().decimal(number, format=format)
-decimalfmt = register.filter(decimalfmt)
-
-def currencyfmt(number, currency):
-    return _get_format().currency(number, currency)
-currencyfmt = register.filter(currencyfmt)
-
-def percentfmt(number, format=None):
-    return _get_format().percent(number, format=format)
-percentfmt = register.filter(percentfmt)
-
-def scientificfmt(number):
-    return _get_format().scientific(number)
-scientificfmt = register.filter(scientificfmt)

+ 0 - 5
desktop/core/ext-py/BabelDjango-0.2.2/setup.cfg

@@ -1,5 +0,0 @@
-[egg_info]
-tag_build = 
-tag_date = 0
-tag_svn_revision = 0
-

+ 0 - 36
desktop/core/ext-py/BabelDjango-0.2.2/setup.py

@@ -1,36 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2007 Edgewall Software
-# All rights reserved.
-#
-# This software is licensed as described in the file COPYING, which
-# you should have received as part of this distribution. The terms
-# are also available at http://babel.edgewall.org/wiki/License.
-#
-# This software consists of voluntary contributions made by many
-# individuals. For the exact contribution history, see the revision
-# history and logs, available at http://babel.edgewall.org/log/.
-
-try:
-    from setuptools import setup
-except ImportError:
-    from distutils.core import setup
-
-setup(
-    name = 'BabelDjango',
-    description = 'Utilities for using Babel in Django',
-    version = '0.2.2',
-    license = 'BSD',
-    author  = 'Edgewall Software',
-    author_email = 'python-babel@googlegroups.com',
-    url = 'http://babel.edgewall.org/wiki/BabelDjango',
-
-    packages = ['babeldjango', 'babeldjango.templatetags'],
-    install_requires = ['Babel'],
-
-    entry_points = """
-    [babel.extractors]
-    django = babeldjango.extract:extract_django
-    """,
-)

+ 1 - 1
desktop/core/requirements.txt

@@ -1,7 +1,6 @@
 asn1crypto==0.24.0
 avro-python3==1.8.2
 Babel==2.5.1
-BabelDjango==0.2.2
 boto==2.46.1
 celery[redis]==4.4.5  # For Python 3.8
 cffi==1.13.2
@@ -12,6 +11,7 @@ cryptography==3.2
 django-auth-ldap==1.3.0
 Django==1.11.29 # Django 2 then 3?
 django-axes==2.2.0
+django_babel==0.6.2
 django-celery-beat==1.4.0
 django_celery_results==1.0.4
 django-crequest==2018.5.11

+ 14 - 13
desktop/core/src/desktop/middleware.py

@@ -44,6 +44,7 @@ from django.urls import resolve
 from django.http import HttpResponseRedirect, HttpResponse
 from django.utils.translation import ugettext as _
 from django.utils.http import urlquote, is_safe_url
+from django.utils.deprecation import MiddlewareMixin
 
 from hadoop import cluster
 from useradmin.models import User
@@ -77,7 +78,7 @@ if ENABLE_PROMETHEUS.get():
   DJANGO_VIEW_AUTH_WHITELIST.append(django_prometheus.exports.ExportToDjangoView)
 
 
-class AjaxMiddleware(object):
+class AjaxMiddleware(MiddlewareMixin):
   """
   Middleware that augments request to set request.ajax
   for either is_ajax() (looks at HTTP headers) or ?format=json
@@ -88,7 +89,7 @@ class AjaxMiddleware(object):
     return None
 
 
-class ExceptionMiddleware(object):
+class ExceptionMiddleware(MiddlewareMixin):
   """
   If exceptions know how to render themselves, use that.
   """
@@ -118,7 +119,7 @@ class ExceptionMiddleware(object):
     return None
 
 
-class ClusterMiddleware(object):
+class ClusterMiddleware(MiddlewareMixin):
   """
   Manages setting request.fs and request.jt
   """
@@ -142,7 +143,7 @@ class ClusterMiddleware(object):
     request.jt = None
 
 
-class NotificationMiddleware(object):
+class NotificationMiddleware(MiddlewareMixin):
   """
   Manages setting request.info and request.error
   """
@@ -269,7 +270,7 @@ class AppSpecificMiddleware(object):
     return result
 
 
-class LoginAndPermissionMiddleware(object):
+class LoginAndPermissionMiddleware(MiddlewareMixin):
   """
   Middleware that forces all views (except those that opt out) through authentication.
   """
@@ -389,7 +390,7 @@ class JsonMessage(object):
 
 class AuditLoggingMiddleware(object):
 
-  def __init__(self):
+  def __init__(self, get_response=None):
     self.impersonator = SERVER_USER.get()
 
     if not AUDIT_EVENT_LOG_DIR.get():
@@ -551,7 +552,7 @@ class HtmlValidationMiddleware(object):
 
 class ProxyMiddleware(object):
 
-  def __init__(self):
+  def __init__(self, get_response=None):
     if not 'desktop.auth.backend.AllowAllBackend' in AUTH.BACKEND.get():
       LOG.info('Unloading ProxyMiddleware')
       raise exceptions.MiddlewareNotUsed
@@ -613,7 +614,7 @@ class SpnegoMiddleware(object):
   http://code.activestate.com/recipes/576992/
   """
 
-  def __init__(self):
+  def __init__(self, get_response=None):
     if not set(AUTH.BACKEND.get()).intersection(
         set(['desktop.auth.backend.SpnegoDjangoBackend', 'desktop.auth.backend.KnoxSpnegoDjangoBackend'])
       ):
@@ -782,14 +783,14 @@ class HueRemoteUserMiddleware(RemoteUserMiddleware):
   unload the middleware if the RemoteUserDjangoBackend is not currently
   in use.
   """
-  def __init__(self):
+  def __init__(self, get_respose=None):
     if not 'desktop.auth.backend.RemoteUserDjangoBackend' in AUTH.BACKEND.get():
       LOG.info('Unloading HueRemoteUserMiddleware')
       raise exceptions.MiddlewareNotUsed
     self.header = AUTH.REMOTE_USER_HEADER.get()
 
 
-class EnsureSafeMethodMiddleware(object):
+class EnsureSafeMethodMiddleware(MiddlewareMixin):
   """
   Middleware to white list configured HTTP request methods.
   """
@@ -798,7 +799,7 @@ class EnsureSafeMethodMiddleware(object):
       return HttpResponseNotAllowed(HTTP_ALLOWED_METHODS.get())
 
 
-class EnsureSafeRedirectURLMiddleware(object):
+class EnsureSafeRedirectURLMiddleware(MiddlewareMixin):
   """
   Middleware to white list configured redirect URLs.
   """
@@ -826,7 +827,7 @@ class EnsureSafeRedirectURLMiddleware(object):
       return response
 
 
-class MetricsMiddleware(object):
+class MetricsMiddleware(MiddlewareMixin):
   """
   Middleware to track the number of active requests.
   """
@@ -865,7 +866,7 @@ class MimeTypeJSFileFixStreamingMiddleware(object):
   as "text/x-js" and if strict X-Content-Type-Options=nosniff is set then browser fails to
   execute javascript file.
   """
-  def __init__(self):
+  def __init__(self, get_response=None):
     jsmimetypes = ['application/javascript', 'application/ecmascript']
     if mimetypes.guess_type("dummy.js")[0] in jsmimetypes:
       LOG.info('Unloading MimeTypeJSFileFixStreamingMiddleware')

+ 14 - 14
desktop/core/src/desktop/settings.py

@@ -143,7 +143,7 @@ GTEMPLATE_LOADERS = (
   'django.template.loaders.app_directories.Loader'
 )
 
-MIDDLEWARE_CLASSES = [
+MIDDLEWARE = [
     # The order matters
     'desktop.middleware.MetricsMiddleware',
     'desktop.middleware.EnsureSafeMethodMiddleware',
@@ -155,7 +155,7 @@ MIDDLEWARE_CLASSES = [
     'desktop.middleware.SpnegoMiddleware',
     'desktop.middleware.HueRemoteUserMiddleware',
     'django.middleware.locale.LocaleMiddleware',
-    'babeldjango.middleware.LocaleMiddleware',
+    'django_babel.middleware.LocaleMiddleware',
     'desktop.middleware.AjaxMiddleware',
     'django.middleware.security.SecurityMiddleware',
     'django.middleware.clickjacking.XFrameOptionsMiddleware',
@@ -176,7 +176,7 @@ MIDDLEWARE_CLASSES = [
 ]
 
 # if os.environ.get(ENV_DESKTOP_DEBUG):
-#   MIDDLEWARE_CLASSES.append('desktop.middleware.HtmlValidationMiddleware')
+#   MIDDLEWARE.append('desktop.middleware.HtmlValidationMiddleware')
 #   logging.debug("Will try to validate generated HTML.")
 
 ROOT_URLCONF = 'desktop.urls'
@@ -202,7 +202,7 @@ INSTALLED_APPS = [
     #'south', # database migration tool
 
     # i18n support
-    'babeldjango',
+    'django_babel',
 
     # Desktop injects all the other installed apps into here magically.
     'desktop',
@@ -549,7 +549,7 @@ if SAML_AUTHENTICATION:
 
 # Middleware classes.
 for middleware in desktop.conf.MIDDLEWARE.get():
-  MIDDLEWARE_CLASSES.append(middleware)
+  MIDDLEWARE.append(middleware)
 
 
 # OpenID Connect
@@ -562,7 +562,7 @@ if is_oidc_configured():
     # when multi-backend auth, standard login URL '/hue/accounts/login' is used.
     LOGIN_URL = '/oidc/authenticate/'
   SESSION_EXPIRE_AT_BROWSER_CLOSE = True
-  MIDDLEWARE_CLASSES.append('mozilla_django_oidc.middleware.SessionRefresh')
+  MIDDLEWARE.append('mozilla_django_oidc.middleware.SessionRefresh')
   OIDC_RENEW_ID_TOKEN_EXPIRY_SECONDS = 15 * 60
   OIDC_RP_SIGN_ALGO = 'RS256'
   OIDC_RP_CLIENT_ID = desktop.conf.OIDC.OIDC_RP_CLIENT_ID.get()
@@ -591,7 +591,7 @@ if OAUTH_AUTHENTICATION:
 
 # URL Redirection white list.
 if desktop.conf.REDIRECT_WHITELIST.get():
-  MIDDLEWARE_CLASSES.append('desktop.middleware.EnsureSafeRedirectURLMiddleware')
+  MIDDLEWARE.append('desktop.middleware.EnsureSafeRedirectURLMiddleware')
 
 # Enable X-Forwarded-Host header if the load balancer requires it
 USE_X_FORWARDED_HOST = desktop.conf.USE_X_FORWARDED_HOST.get()
@@ -602,10 +602,10 @@ if desktop.conf.SECURE_PROXY_SSL_HEADER.get():
 
 # Add last activity tracking and idle session timeout
 if 'useradmin' in [app.name for app in appmanager.DESKTOP_APPS]:
-  MIDDLEWARE_CLASSES.append('useradmin.middleware.LastActivityMiddleware')
+  MIDDLEWARE.append('useradmin.middleware.LastActivityMiddleware')
 
 if desktop.conf.SESSION.CONCURRENT_USER_SESSION_LIMIT.get():
-  MIDDLEWARE_CLASSES.append('useradmin.middleware.ConcurrentUserSessionMiddleware')
+  MIDDLEWARE.append('useradmin.middleware.ConcurrentUserSessionMiddleware')
 
 LOAD_BALANCER_COOKIE = 'ROUTEID'
 
@@ -692,8 +692,8 @@ def show_toolbar(request):
   return DEBUG and desktop.conf.ENABLE_DJANGO_DEBUG_TOOL.get() and is_user_allowed
 
 if DEBUG and desktop.conf.ENABLE_DJANGO_DEBUG_TOOL.get():
-  idx = MIDDLEWARE_CLASSES.index('desktop.middleware.ClusterMiddleware')
-  MIDDLEWARE_CLASSES.insert(idx + 1, 'debug_panel.middleware.DebugPanelMiddleware')
+  idx = MIDDLEWARE.index('desktop.middleware.ClusterMiddleware')
+  MIDDLEWARE.insert(idx + 1, 'debug_panel.middleware.DebugPanelMiddleware')
 
   INSTALLED_APPS += (
       'debug_toolbar',
@@ -760,8 +760,8 @@ if desktop.conf.TASK_SERVER.ENABLED.get() or desktop.conf.TASK_SERVER.BEAT_ENABL
 
 PROMETHEUS_EXPORT_MIGRATIONS = False # Needs to be there even when enable_prometheus is not enabled
 if desktop.conf.ENABLE_PROMETHEUS.get():
-  MIDDLEWARE_CLASSES.insert(0, 'django_prometheus.middleware.PrometheusBeforeMiddleware')
-  MIDDLEWARE_CLASSES.append('django_prometheus.middleware.PrometheusAfterMiddleware')
+  MIDDLEWARE.insert(0, 'django_prometheus.middleware.PrometheusBeforeMiddleware')
+  MIDDLEWARE.append('django_prometheus.middleware.PrometheusAfterMiddleware')
 
   if 'mysql' in DATABASES['default']['ENGINE']:
     DATABASES['default']['ENGINE'] = DATABASES['default']['ENGINE'].replace('django.db.backends', 'django_prometheus.db.backends')
@@ -795,7 +795,7 @@ if desktop.conf.TRACING.ENABLED.get():
 
   OPENTRACING_TRACED_ATTRIBUTES = ['META']  # Only valid if OPENTRACING_TRACE_ALL == True
   if desktop.conf.TRACING.TRACE_ALL.get():
-    MIDDLEWARE_CLASSES.insert(0, 'django_opentracing.OpenTracingMiddleware')
+    MIDDLEWARE.insert(0, 'django_opentracing.OpenTracingMiddleware')
 
 MODULES_TO_PATCH = (
     'django.contrib.staticfiles.storage',