{"id":13448789,"url":"https://github.com/bradmontgomery/django-querycount","last_synced_at":"2025-05-16T01:05:47.050Z","repository":{"id":18556100,"uuid":"21757804","full_name":"bradmontgomery/django-querycount","owner":"bradmontgomery","description":"Middleware that Prints the number of DB queries to the runserver console.","archived":false,"fork":false,"pushed_at":"2024-05-29T09:35:31.000Z","size":583,"stargazers_count":395,"open_issues_count":13,"forks_count":32,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-05-09T15:41:24.682Z","etag":null,"topics":["database","debugging","developer-tools","django","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bradmontgomery.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.rst","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-07-12T02:35:02.000Z","updated_at":"2025-05-05T10:09:35.000Z","dependencies_parsed_at":"2024-06-18T15:34:11.008Z","dependency_job_id":"32b47043-b45a-40b5-8d76-4412b8a41154","html_url":"https://github.com/bradmontgomery/django-querycount","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradmontgomery%2Fdjango-querycount","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradmontgomery%2Fdjango-querycount/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradmontgomery%2Fdjango-querycount/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradmontgomery%2Fdjango-querycount/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bradmontgomery","download_url":"https://codeload.github.com/bradmontgomery/django-querycount/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254448579,"owners_count":22072764,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","debugging","developer-tools","django","python"],"created_at":"2024-07-31T06:00:21.134Z","updated_at":"2025-05-16T01:05:42.036Z","avatar_url":"https://github.com/bradmontgomery.png","language":"Python","readme":"Django Querycount\n=================\n\n|version| |license|\n\nInspired by `this post by David Szotten \u003chttp://goo.gl/UUKN0r\u003e`_, this project\ngives you a middleware that prints DB query counts in Django's runserver\nconsole output.\n\n|screenshot|\n\n\nInstallation\n------------\n\n    pip install django-querycount\n\nJust add ``querycount.middleware.QueryCountMiddleware`` to your\n``MIDDLEWARE``.\n\nNotice that django-querycount is hard coded to work only in DEBUG mode set to true\n\nSettings\n--------\n\nThere are two possible settings for this app: The first defines threshold\nvalues used to color output, while the second allows you customize requests\nthat will be ignored by the middleware.  The default settings are::\n\n    QUERYCOUNT = {\n        'THRESHOLDS': {\n            'MEDIUM': 50,\n            'HIGH': 200,\n            'MIN_TIME_TO_LOG':0,\n            'MIN_QUERY_COUNT_TO_LOG':0\n        },\n        'IGNORE_REQUEST_PATTERNS': [],\n        'IGNORE_SQL_PATTERNS': [],\n        'DISPLAY_DUPLICATES': None,\n        'RESPONSE_HEADER': 'X-DjangoQueryCount-Count'\n    }\n\n\nThe ``QUERYCOUNT['THRESHOLDS']`` settings will determine how many queries are\ninterpreted as high or medium (and the color-coded output). In previous versions\nof this app, this settings was called ``QUERYCOUNT_THRESHOLDS`` and that setting\nis still supported.\n\nThe ``QUERYCOUNT['IGNORE_REQUEST_PATTERNS']`` setting allows you to define a list of\nregexp patterns that get applied to each request's path. If there is a match,\nthe middleware will not be applied to that request. For example, the following\nsetting would bypass the querycount middleware for all requests to the admin::\n\n    QUERYCOUNT = {\n        'IGNORE_REQUEST_PATTERNS': [r'^/admin/']\n    }\n\nThe ``QUERYCOUNT['IGNORE_SQL_PATTERNS']`` setting allows you to define a list of\nregexp patterns that ignored to statistic sql query count. For example, the following\nsetting would bypass the querycount middleware for django-silk sql query::\n\n    QUERYCOUNT = {\n        'IGNORE_SQL_PATTERNS': [r'silk_']\n    }\n\nThe ``QUERYCOUNT['RESPONSE_HEADER']`` setting allows you to define a custom response\nheader that contains the total number of queries executed. To disable this header, \nthe supply ``None`` as the value::\n\n    QUERYCOUNT = {\n        'RESPONSE_HEADER': None\n    }\n\n**New in 0.4.0**. The ``QUERYCOUNT['DISPLAY_DUPLICATES']`` setting allows you\nto control how the most common duplicate queries are displayed. If the setting\nis ``None`` (the default), duplicate queries are not displayed. Otherwise, this\nshould be an integer. For example, the following setting would always print the\n5 most duplicated queries::\n\n    QUERYCOUNT = {\n        'DISPLAY_DUPLICATES': 5,\n    }\n\n\nLicense\n-------\n\nThis code is distributed under the terms of the MIT license.\n\nTesting\n-------\n\nRun `python manage.py test querycount` to run the tests. Note that this will\nmodify your settings so that your project is in DEBUG mode for the duration\nof the `querycount` tests.\n\n(side-note: this project needs better tests; for the moment, there are only\nsmoke tests that set up the middleware and call two simple test views).\n\n\nContributing\n------------\n\nBug fixes and new features are welcome! Fork this project and send a Pull Request\nto have your work included. Be sure to add yourself to ``AUTHORS.rst``.\n\n\n.. |version| image:: http://img.shields.io/pypi/v/django-querycount.svg?style=flat-square\n    :alt: Current Release\n    :target: https://pypi.python.org/pypi/django-querycount/\n\n.. |license| image:: http://img.shields.io/pypi/l/django-querycount.svg?style=flat-square\n    :alt: License\n    :target: https://pypi.python.org/pypi/django-querycount/\n\n.. |screenshot| image:: screenshot.png\n    :alt: django-querycount in action\n","funding_links":[],"categories":["Python","Debugging"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbradmontgomery%2Fdjango-querycount","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbradmontgomery%2Fdjango-querycount","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbradmontgomery%2Fdjango-querycount/lists"}