The missing debug tool for Django, inspired by Telescope.
Project description
DjangoSonar
The missing debug tool for django.
DjangoSonar is a comprehensive debugging and introspection tool for Django applications, inspired by Laravel Telescope.
🥳 Motivation
Having spent years developing with Laravel before switching to Django, the first thing I missed from this change was the amazing Laravel Telescope. So, I decided to create it myself.
DjangoSonar is built using:
If you use this project, please consider giving it a ⭐.
⭐ Features
- Self updating lists of:
- Requests
- Exceptions
- Queries
- Dumps
- (Signals coming soon™)
- Request insights:
- Payload get/post
- Auth User
- Session vars
- Headers
- ...
- Historical data (clearable)
- Simple and reactive UI
🛠️ How to install
- First you need to install the package:
pip install django-sonar
- Then, to enable the dashboard, you will need to add the app to the INSTALLED_APPS in your project main settings file:
INSTALLED_APPS = [
...
'django_sonar',
...
]
- Add the urls to the main urls.py file in your project folder:
urlpatterns = [
...
path('sonar/', include('django_sonar.urls')),
...
]
- 🔔 Be sure to add the exclusions settings too, or you will get way too much data in your sonar dashboard:
DJANGO_SONAR = {
'excludes': [
STATIC_URL,
MEDIA_URL,
'/sonar/',
'/admin/',
'/__reload__/',
],
}
In this example I'm excluding all the http requests to static files, uploads, the sonar dashboard itself, the django admin panels and the browser reload library. Update this setting accordingly, YMMW.
- Now you should be able to execute the migrations to create the two tables that DjangoSonar will use to collect the data.
python manage.py migrate
- And finally add the DjangoSonar middleware to your middlewares to enable the data collection:
MIDDLEWARE = [
...
'django_sonar.middlewares.requests.RequestsMiddleware',
...
]
😎 How to use
The Dashboard
To access the dashboard you will point your browser to the /sonar/ url (but you can change it as described before). The interface is very simple and self explanatory.
You could use DjangoSonar in production too, since it gives you an historical overview of all the requests, but be sure to clear the data and disable it when you have debugged the problem.
🔔 If you forget to disable/clear DjangoSonar you could end up with several gigabytes of data collected. So please use it with caution when in production 🔔
Only authenticated superusers can access sonar. If you are trying to access the dashboard with a wrong type of user, you will see an error page, otherwise you should see the DjangoSonar login page.
sonar() - the dump helper
You can dump values to DjangoSonar using the sonar() helper function:
from django_sonar.utils import sonar
sonar('something')
And you can also dump multiple values like this:
from django_sonar.utils import sonar
sonar('something', self.request.GET, [1,2,3])
⚖️ License
DjangoSonar is open-sourced software licensed under the MIT license.
🍺 Donations
If you really like this project and you want to help me please consider buying me a beer 🍺
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django_sonar-0.1.8.tar.gz
.
File metadata
- Download URL: django_sonar-0.1.8.tar.gz
- Upload date:
- Size: 287.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38f86c97696e4cae3e9386b4178a1a9a85177e00ec6d189aae71852c537deb4f |
|
MD5 | 795d5cab3a26b9a3fac1260c65a92269 |
|
BLAKE2b-256 | c401e8a7f6e595d1f424fff83b9dc3d89386faf4cead82b761ef8d58d24de0de |
File details
Details for the file django_sonar-0.1.8-py3-none-any.whl
.
File metadata
- Download URL: django_sonar-0.1.8-py3-none-any.whl
- Upload date:
- Size: 296.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | add002dfb29002b742a5e3a829986edad8ea97eb39e6d1420fa461b988ffdb00 |
|
MD5 | b54f37f1b0fca7d9dceeac0ce182c150 |
|
BLAKE2b-256 | 4329282fcc6d067fb7af3f1dc105160da6d3eff888fdc46ec1c3de33604c7bf3 |