From 360bffb155a6975fea94154bb2a72584504f7fa7 Mon Sep 17 00:00:00 2001 From: Goto Hayato Date: Wed, 28 Feb 2018 12:43:06 +0900 Subject: [PATCH] Issue #41: Fix MIDDLEWARE_CLASSES error with `runserver` on django >= 1.10. --- django_pdb/management/commands/runserver.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/django_pdb/management/commands/runserver.py b/django_pdb/management/commands/runserver.py index 68bf91f..56c4efe 100644 --- a/django_pdb/management/commands/runserver.py +++ b/django_pdb/management/commands/runserver.py @@ -54,10 +54,13 @@ def handle(self, *args, **options): pdb_option = options.pop('pdb') ipdb_option = options.pop('ipdb') - middleware = 'django_pdb.middleware.PdbMiddleware' + pdb_middleware = 'django_pdb.middleware.PdbMiddleware' + middleware = (settings.MIDDLEWARE + if hasattr(settings, 'MIDDLEWARE') + else settings.MIDDLEWARE_CLASSES) if ((pdb_option or settings.DEBUG) - and middleware not in settings.MIDDLEWARE_CLASSES): - settings.MIDDLEWARE_CLASSES += (middleware,) + and pdb_middleware not in middleware): + middleware += (pdb_middleware,) self.pm = options.pop('pm') if self.pm: