|
6 | 6 |
|
7 | 7 | import django |
8 | 8 | from asgiref.sync import sync_to_async |
| 9 | +from django.apps import apps |
9 | 10 | from django.contrib.auth.models import User |
10 | 11 | from django.db import connection, transaction |
11 | 12 | from django.db.backends.utils import CursorDebugWrapper, CursorWrapper |
12 | 13 | from django.db.models import Count |
13 | 14 | from django.db.utils import DatabaseError |
14 | 15 | from django.shortcuts import render |
15 | 16 | from django.test.utils import override_settings |
16 | | -from django.apps import apps |
17 | 17 |
|
18 | 18 | import debug_toolbar.panels.sql.tracking as sql_tracking |
| 19 | +from debug_toolbar import settings as dt_settings |
19 | 20 | from debug_toolbar.models import HistoryEntry |
20 | 21 | from debug_toolbar.panels.sql import SQLPanel, tracking |
21 | | -from debug_toolbar import settings as dt_settings |
22 | 22 |
|
23 | 23 | try: |
24 | 24 | import psycopg |
@@ -61,9 +61,13 @@ async def concurrent_async_sql_call(*, use_iterator=False): |
61 | 61 | qs = qs.iterator() |
62 | 62 | return await asyncio.gather(sync_to_async(list)(qs), User.objects.acount()) |
63 | 63 |
|
| 64 | + |
64 | 65 | def fetch_ddt_models(): |
65 | 66 | """Helper function to fetches the models of the 'debug_toolbar' app, but only when the toolbar is configured to use the debug_toolbar.store.DatabaseStore.""" |
66 | | - if dt_settings.get_config()['TOOLBAR_STORE_CLASS'] == 'debug_toolbar.store.DatabaseStore': |
| 67 | + if ( |
| 68 | + dt_settings.get_config()["TOOLBAR_STORE_CLASS"] |
| 69 | + == "debug_toolbar.store.DatabaseStore" |
| 70 | + ): |
67 | 71 | apps.get_app_config("debug_toolbar").import_models() |
68 | 72 | tracking.DDT_MODELS = { |
69 | 73 | m._meta.db_table for m in apps.get_app_config("debug_toolbar").get_models() |
|
0 commit comments