Django-Sonar is becoming a pivotal tool for debugging and introspection tailored for Django applications, inspired by the Laravel Telescope's functionality.

It aims to address the gap felt by developers transitioning from Laravel to Django, missing the robust debugging capabilities Laravel Telescope offered.


What is Django-Sonar?

Django-Sonar is an advanced debugging tool for Django applications, aimed at offering deep insights into various operational aspects such as requests, exceptions, and database queries.

It's designed to enhance the debugging process by providing a detailed and dynamic overview of application performance and issues, thereby streamlining the identification and resolution of bugs.

Inspired by the Laravel Telescope, Django-Sonar brings a similar level of debugging prowess to Django, leveraging technologies like Django itself, Bootstrap 5, and htmx to create a reactive and user-friendly interface for developers.


Key Features

Here are some of the key features of Django-Sonar:

  • Dynamic Lists: Automatically updating lists including requests, exceptions, queries, dumps, and more.
  • Request Insights: Detailed view of request payloads, authentication details, session variables, and headers.
  • Historical Data Management: Enables the review and clearance of historical data to maintain efficiency.
  • User-Friendly Interface: A simple, reactive UI that makes navigation and operation straightforward.

Excited to dive deeper into the world of Python programming? Look no further than my latest ebook, "Python Tricks - A Collection of Tips and Techniques".

Get the eBook

Inside, you'll discover a plethora of Python secrets that will guide you through a journey of learning how to write cleaner, faster, and more Pythonic code. Whether it's mastering data structures, understanding the nuances of object-oriented programming, or uncovering Python's hidden features, this ebook has something for everyone.

Installation

Installation is done with the standard package installation:

pip install django-sonar

Then, add the application to the list of INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    'django_sonar',
    ...
]

You will also need to add the application URLs to the main urls.py file:

urlpatterns = [
    ...
    path('sonar/', include('django_sonar.urls')),
    ...
]

To avoid collecting too much data/noise, it is advisable to configure some exclusions in the settings.py file:

DJANGO_SONAR = {
    'excludes': [
        STATIC_URL,
        MEDIA_URL,
        '/sonar/',
        '/admin/',
        '/__reload__/',
    ],
}

In this example, all HTTP requests targeting static files, uploads, the Sonar dashboard, Django admin panels, and the browser reload library are being excluded. Feel free to adjust to your needs.

To enable the data collection, you need to add a new middleware in the settings.py file:

MIDDLEWARE = [
    ...
    'django_sonar.middlewares.requests.RequestsMiddleware',
    ...
]

Finally, run the migrations to prepare the data collection tables:

python manage.py migrate

Usage

To view the dashboard, navigate to the /sonar/ URL in your browser. The interface is straightforward:

Tagged in: