|
6 | 6 |
|
7 | 7 | import uuid
|
8 | 8 | from collections import OrderedDict
|
9 |
| -from importlib import import_module |
10 | 9 |
|
11 | 10 | from django.apps import apps
|
12 | 11 | from django.conf.urls import url
|
13 | 12 | from django.core.exceptions import ImproperlyConfigured
|
14 | 13 | from django.template import TemplateSyntaxError
|
15 | 14 | from django.template.loader import render_to_string
|
| 15 | +from django.utils.module_loading import import_string |
16 | 16 |
|
17 | 17 | from debug_toolbar import settings as dt_settings
|
18 | 18 |
|
@@ -106,27 +106,10 @@ def fetch(cls, store_id):
|
106 | 106 | def get_panel_classes(cls):
|
107 | 107 | if cls._panel_classes is None:
|
108 | 108 | # Load panels in a temporary variable for thread safety.
|
109 |
| - panel_classes = [] |
110 |
| - for panel_path in dt_settings.get_panels(): |
111 |
| - # This logic could be replaced with import_by_path in Django 1.6. |
112 |
| - try: |
113 |
| - panel_module, panel_classname = panel_path.rsplit('.', 1) |
114 |
| - except ValueError: |
115 |
| - raise ImproperlyConfigured( |
116 |
| - "%s isn't a debug panel module" % panel_path) |
117 |
| - try: |
118 |
| - mod = import_module(panel_module) |
119 |
| - except ImportError as e: |
120 |
| - raise ImproperlyConfigured( |
121 |
| - 'Error importing debug panel %s: "%s"' % |
122 |
| - (panel_module, e)) |
123 |
| - try: |
124 |
| - panel_class = getattr(mod, panel_classname) |
125 |
| - except AttributeError: |
126 |
| - raise ImproperlyConfigured( |
127 |
| - 'Toolbar Panel module "%s" does not define a "%s" class' % |
128 |
| - (panel_module, panel_classname)) |
129 |
| - panel_classes.append(panel_class) |
| 109 | + panel_classes = [ |
| 110 | + import_string(panel_path) |
| 111 | + for panel_path in dt_settings.get_panels() |
| 112 | + ] |
130 | 113 | cls._panel_classes = panel_classes
|
131 | 114 | return cls._panel_classes
|
132 | 115 |
|
|
0 commit comments