$ account django-commons
The Django Debug Toolbar is a development tool that provides configurable panels to display debug information about Django requests/responses. It integrates via middleware to intercept requests, collects data from panels (SQL queries, cache usage, template rendering, etc.), and injects an interactive toolbar into responses. The architecture features a plugin-based panel system, storage abstraction layer (memory/database/cache backends), and conditional rendering based on IP addresses and debug mode. Key entry points include DebugToolbarMiddleware, the DebugToolbar class, and panel-specific views. Data flows involve request processing, asynchronous panel data fetching via AJAX, and response injection. While primarily a debugging utility, it includes data storage mechanisms for historical request inspection. The toolkit demonstrates strong engineering practices through its extensible panel system, storage abstraction, and async/sync middleware compatibility.
django-click is a library that bridges the Click CLI framework with Django's management command system. It allows developers to write Django management commands using Click's decorator-based API instead of the traditional Django BaseCommand class. The library provides a drop-in replacement for Click's `command` and `group` decorators that automatically register the decorated function as a Django management command, handling all the integration details such as argument parsing, help output, verbosity, settings, and color support. The architecture consists of adapter classes (`DjangoCommandMixin`, `CommandAdapter`, `GroupAdapter`) that inherit from Click's `Command` and `Group` classes and override key methods (`run_from_argv`, `create_parser`, `execute`, `print_help`) to conform to Django's command execution protocol. A `BaseRegistrator` class handles the registration process: it extracts the command name from the module name, applies Click decorators with common Django options (verbosity, settings, pythonpath, traceback, color), and sets the module-level `Command` attribute to a lambda that returns the Click command instance. This enables seamless integration with both `manage.py` invocation and `call_command()` usage. The library also provides a `pass_verbosity` decorator for accessing the Django verbosity level within Click commands, and a `ModelInstance` custom parameter type that allows commands to accept Django model instances as arguments with support for custom lookups. The code is well-tested with comprehensive test coverage for CLI invocation, `call_command` integration, error handling, color support, and edge cases like abort handling and stdout/stderr capture.