├── .github └── workflows │ └── codeql-analysis.yml ├── .gitignore ├── LICENSE ├── MANIFEST.in ├── README.md ├── ddt_request_history ├── __init__.py └── panels │ ├── __init__.py │ ├── request_history.html │ └── request_history.py ├── setup.cfg └── setup.py /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ master ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ master ] 20 | schedule: 21 | - cron: '41 9 * * 0' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | 28 | strategy: 29 | fail-fast: false 30 | matrix: 31 | language: [ 'python' ] 32 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] 33 | # Learn more: 34 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed 35 | 36 | steps: 37 | - name: Checkout repository 38 | uses: actions/checkout@v2 39 | 40 | # Initializes the CodeQL tools for scanning. 41 | - name: Initialize CodeQL 42 | uses: github/codeql-action/init@v1 43 | with: 44 | languages: ${{ matrix.language }} 45 | # If you wish to specify custom queries, you can do so here or in a config file. 46 | # By default, queries listed here will override any specified in a config file. 47 | # Prefix the list here with "+" to use these queries and those in the config file. 48 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 49 | 50 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 51 | # If this step fails, then you should remove it and run the build manually (see below) 52 | - name: Autobuild 53 | uses: github/codeql-action/autobuild@v1 54 | 55 | # ℹ️ Command-line programs to run using the OS shell. 56 | # 📚 https://git.io/JvXDl 57 | 58 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 59 | # and modify them (or add more) to build your code if your project 60 | # uses a compiled language 61 | 62 | #- run: | 63 | # make bootstrap 64 | # make release 65 | 66 | - name: Perform CodeQL Analysis 67 | uses: github/codeql-action/analyze@v1 68 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | .idea/ 3 | build/ 4 | dist/ 5 | django_debug_toolbar_request_history.egg-info/ 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, David Sutherland 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the {organization} nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.md LICENSE 2 | recursive-include ddt_request_history *.py *.html -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Update: History is now built into Django Debug Toolbar # 2 | 3 | Since version [3.0](https://django-debug-toolbar.readthedocs.io/en/latest/changes.html#) of Django Debug Toolbar a built in history panel is available. More details can be found in this [PR](https://github.com/jazzband/django-debug-toolbar/pull/1250) and the [docs](https://django-debug-toolbar.readthedocs.io/en/latest/panels.html#history). As this functionality is being provided by the toolbar itself there will likely not be any further updates to this project (though if there are good reasons for an exception like supporting older versions of the toolbar it will be considered). Thanks to all those who've contributed to and used this project. 4 | 5 | ## Request History Panel for Django Debug Toolbar ## 6 | 7 | Adds a request history panel to [Django Debug Toolbar](https://github.com/django-debug-toolbar/django-debug-toolbar) for viewing stats for different requests (with the option for ajax support). 8 | 9 | 10 | ### Install ### 11 | 12 | ```bash 13 | pip install django-debug-toolbar-request-history 14 | ``` 15 | 16 | Then add the panel to ```DEBUG_TOOLBAR_PANELS``` (see the config section for more details). 17 | 18 | **Note: only Django Debug Toolbar versions 2.0 and higher are now supported. For older versions try:** 19 | 20 | ```bash 21 | pip install django-debug-toolbar-request-history==0.0.11 22 | ``` 23 | 24 | or for the development version: 25 | 26 | ```bash 27 | pip install -e git+https://github.com/djsutho/django-debug-toolbar-request-history.git#egg=django-debug-toolbar-request-history 28 | ``` 29 | 30 | ### Usage ### 31 | 32 | * Click on the "Request History" panel in the toolbar to load the available requests 33 | * Click on the request you are interested in (on the "Time" or "Path" part of the request) to load the toolbar for that request 34 | 35 | 36 | **Notes** 37 | 38 | Due to django-debug-toolbar reliance on thread-local: 39 | - currently requests do not survive server reload, therefore, when using the dev server old requests will not be available after a code change is loaded 40 | - if you get inconsistent request history each time you click on the panel, lower your server threads to 1 41 | 42 | 43 | ### Config (in settings.py) ### 44 | 45 | To ```DEBUG_TOOLBAR_PANELS``` add ```'ddt_request_history.panels.request_history.RequestHistoryPanel'``` e.g.: 46 | 47 | ```python 48 | DEBUG_TOOLBAR_PANELS = [ 49 | 'ddt_request_history.panels.request_history.RequestHistoryPanel', # Here it is 50 | 'debug_toolbar.panels.versions.VersionsPanel', 51 | 'debug_toolbar.panels.timer.TimerPanel', 52 | 'debug_toolbar.panels.settings.SettingsPanel', 53 | 'debug_toolbar.panels.headers.HeadersPanel', 54 | 'debug_toolbar.panels.request.RequestPanel', 55 | 'debug_toolbar.panels.sql.SQLPanel', 56 | 'debug_toolbar.panels.templates.TemplatesPanel', 57 | 'debug_toolbar.panels.staticfiles.StaticFilesPanel', 58 | 'debug_toolbar.panels.cache.CachePanel', 59 | 'debug_toolbar.panels.signals.SignalsPanel', 60 | 'debug_toolbar.panels.logging.LoggingPanel', 61 | 'debug_toolbar.panels.redirects.RedirectsPanel', 62 | 'debug_toolbar.panels.profiling.ProfilingPanel', 63 | ] 64 | ``` 65 | 66 | To change the number of stored requests add ```RESULTS_STORE_SIZE``` to ```DEBUG_TOOLBAR_CONFIG``` e.g.: 67 | 68 | ```python 69 | DEBUG_TOOLBAR_CONFIG = { 70 | 'RESULTS_STORE_SIZE': 100, 71 | } 72 | ``` 73 | 74 | ### TODO ### 75 | * Clean-up 76 | * Change the storage to survive server reloads (maybe use cache or session). 77 | * Add tests 78 | -------------------------------------------------------------------------------- /ddt_request_history/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djsutho/django-debug-toolbar-request-history/df23cf96f7106453bce087397834aa6e1927621e/ddt_request_history/__init__.py -------------------------------------------------------------------------------- /ddt_request_history/panels/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djsutho/django-debug-toolbar-request-history/df23cf96f7106453bce087397834aa6e1927621e/ddt_request_history/panels/__init__.py -------------------------------------------------------------------------------- /ddt_request_history/panels/request_history.html: -------------------------------------------------------------------------------- 1 | {% load i18n %}{% load static %} 2 |
# | 9 |{% trans "Time" %} | 10 |{% trans "Method" %} | 11 |{% trans "Path" %} | 12 |{% trans "Post Variables" %} | 13 |
---|---|---|---|---|
{{forloop.counter}} | 19 |20 | {{ toolbar.toolbar.stats.RequestHistoryPanel.time|escape }} 21 | | 22 |
23 | {{ toolbar.toolbar.stats.RequestHistoryPanel.request_method|escape }} 24 | |
25 |
26 | {{ toolbar.toolbar.stats.RequestHistoryPanel.request_url|escape }} 27 | |
28 | 29 | + 30 | {% if trunc_length %} 31 | {{ toolbar.toolbar.stats.RequestHistoryPanel.post|truncatechars:trunc_length|escape }} 32 | {% else %} 33 | {{ toolbar.toolbar.stats.RequestHistoryPanel.post|escape }} 34 | {% endif %} 35 | | 36 |