File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
django_mongodb_extensions/mql_panel Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -81,17 +81,20 @@ def content(self):
8181
8282 def disable_instrumentation (self ):
8383 for connection in connections .all ():
84- if hasattr (connection , "_djdt_logger " ):
85- connection ._djdt_logger = None
84+ if hasattr (connection , "_mql_djdt_logger " ):
85+ connection ._mql_djdt_logger = None
8686
8787 def enable_instrumentation (self ):
8888 # Only patch MongoDB connections (those with get_collection method).
8989 # This allows the panel to work in multi-database setups with
9090 # both MongoDB and relational databases.
91+ #
92+ # Use _mql_djdt_logger (not _djdt_logger) to avoid conflicting with the
93+ # SQL panel, which sets _djdt_logger on all connections regardless of type.
9194 for connection in connections .all ():
9295 if hasattr (connection , "get_collection" ):
9396 patch_get_collection (connection )
94- connection ._djdt_logger = self
97+ connection ._mql_djdt_logger = self
9598
9699 def generate_stats (self , request , response ):
97100 duplicate_query_groups = defaultdict (list )
Original file line number Diff line number Diff line change @@ -85,7 +85,9 @@ def patch_get_collection(connection):
8585 connection ._original_get_collection = connection .get_collection
8686
8787 def get_collection (self , name , ** kwargs ):
88- logger = getattr (self , "_djdt_logger" , None )
88+ # Use _mql_djdt_logger (not _djdt_logger) to avoid conflicting with the
89+ # SQL panel, which sets _djdt_logger on all connections.
90+ logger = getattr (self , "_mql_djdt_logger" , None )
8991 if logger :
9092 collection = self ._original_get_collection (name , ** kwargs )
9193 return DebugToolbarWrapper (self , collection , logger )
You can’t perform that action at this time.
0 commit comments