debug_toolbar.core.panel

Base panel class for debug toolbar panels.

Classes

Panel(toolbar)

Abstract base class for debug toolbar panels.

class debug_toolbar.core.panel.Panel(toolbar)[source]

Abstract base class for debug toolbar panels.

Panels are responsible for collecting and displaying specific types of debug information. Each panel should override the abstract methods to provide its functionality.

Class Attributes:

panel_id: Unique identifier for the panel. Defaults to class name. title: Display title shown in the toolbar. template: Template name for rendering the panel content. has_content: Whether this panel has detailed content. nav_title: Short title for the toolbar navigation. nav_subtitle: Subtitle shown in the toolbar navigation.

panel_id: ClassVar[str] = ''
title: ClassVar[str] = ''
template: ClassVar[str] = ''
has_content: ClassVar[bool] = True
nav_title: ClassVar[str] = ''
nav_subtitle: ClassVar[str] = ''
__init__(toolbar)[source]

Initialize the panel.

Parameters:

toolbar (DebugToolbar) – The parent DebugToolbar instance.

classmethod get_panel_id()[source]

Get the panel’s unique identifier.

Return type:

str

Returns:

The panel_id class variable, or the class name if not set.

property enabled: bool

Check if the panel is enabled.

abstractmethod async generate_stats(context)[source]

Generate statistics for this panel.

This method is called during request processing to collect data.

Parameters:

context (RequestContext) – The current request context.

Return type:

dict[str, Any]

Returns:

Dictionary of statistics data.

async process_request(context)[source]

Process the request phase.

Override this to perform actions at the start of request processing.

Parameters:

context (RequestContext) – The current request context.

Return type:

None

async process_response(context)[source]

Process the response phase.

Override this to perform actions at the end of request processing.

Parameters:

context (RequestContext) – The current request context.

Return type:

None

get_stats(context)[source]

Get stored stats from context.

Parameters:

context (RequestContext) – The current request context.

Return type:

dict[str, Any]

Returns:

Dictionary of panel stats.

record_stats(context, stats)[source]

Record stats to the context.

Parameters:
Return type:

None

generate_server_timing(context)[source]

Generate Server-Timing header data.

Override this to contribute to the Server-Timing header.

Parameters:

context (RequestContext) – The current request context.

Return type:

dict[str, float]

Returns:

Dictionary mapping metric names to durations in seconds.

get_nav_title()[source]

Get the navigation title.

Return type:

str

Returns:

The nav_title class variable, or title if not set.

get_nav_subtitle()[source]

Get the navigation subtitle.

Return type:

str

Returns:

The nav_subtitle class variable.