Skip to main content

Django Query Analyzer

Django Query Analyzer is a Django app that allows you to monitor and analyze the database queries executed by your Django application.

Installation

  1. Install the django-query-analyzer package using pip:

    pip install django-query-analyzer
    
  2. Add "django_query_analyzer" to your INSTALLED_APPS setting in your Django project's settings.py:

    INSTALLED_APPS = [
        ...
        'django_query_analyzer',
    ]
    
  3. Add "django_query_analyzer.middleware.QueryAnalyzerMiddleware" to your project's MIDDLEWARE list in settings.py:

    MIDDLEWARE = [
        ...
        "django_query_analyzer.middleware.QueryAnalyzerMiddleware",
    ]
    
  4. Register the query analyzer URL patterns in your project's urls.py:

    from django.urls import path, include
    
    urlpatterns = [
        ...
        path("query-analyzer/", include("django_query_analyzer.urls")),
    ]
    

Usage

  1. Start your Django development server:

    python manage.py runserver
    
  2. Visit the query analyzer dashboard at http://127.0.0.1:8000/query-analyzer/ in your web browser.

Configuration

By default, the query analyzer stores the last 50 executed queries. If you want to control this number, you can add the MAX_QUERY_ANALYZER_RECORDS setting to your project's settings.py. For example, to store the last 100 queries, add the following line to your settings.py:

MAX_QUERY_ANALYZER_RECORDS = 100

Logging to Terminal

You can control logging to the terminal by adding the ENABLE_LOGGING_TO_TERMINAL setting to your project's settings.py. If set to True, query analysis details will be printed to the terminal. To disable terminal logging, set it to `False.

Example configuration in settings.py:

ENABLE_LOGGING_TO_TERMINAL = True

You can control the SQL query to logging the terminal by adding ENABLE_QUERY_LOGGING_ON_CONSOLE to the settings

ENABLE_QUERY_LOGGING_ON_CONSOLE = True

Excluded Paths

You can configure excluded path by configuring the PATHS_TO_EXCLUDE on the settings.py. by adding the list of path prefixes, you can ignore the execution of query analyzer on the paths. By default query analyzer execute on every paths.

Example configuration in settings.py:

PATHS_TO_EXCLUDE = ['/admin/','/swagger/']

Release files for django-query-analyzer 0.0.17

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-query-analyzer 0.0.17
File Size Uploaded
django_query_analyzer-0.0.17.tar.gz 7.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-query-analyzer 0.0.17
File Interpreter ABI Platform
django_query_analyzer-0.0.17-py3-none-any.whl Python 3 none any Details

Total release size: 17.0 kB

Release files / django_query_analyzer-0.0.17.tar.gz

Download URL django_query_analyzer-0.0.17.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d80945414620821f3862b475dc0f2a163ca3f2cf7e09682c771654d71b91c6be
BLAKE2b-256 checksum
How to use checksums
5bcc80dbdb8bb69cbdc2d4b59b74c124f9aab12f463189638adf51827a9ea673
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release files / django_query_analyzer-0.0.17-py3-none-any.whl

Download URL django_query_analyzer-0.0.17-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
49b2b72aeadb9afec457a91f7fc249399dfabab0405a71b6ba4c2117a27bd619
BLAKE2b-256 checksum
How to use checksums
9e1043f86f2219eb3bf829922dc0253d622bc1897d8a436695c8508736ab1acf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release history Release notifications | RSS feed

This release

0.0.17 This release

2 release files

0.0.16

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page