diff options
| author | Aymeric Augustin | 2013-11-10 01:45:30 -0800 |
|---|---|---|
| committer | Aymeric Augustin | 2013-11-10 01:45:30 -0800 |
| commit | 14245b5802d3a4b2a467c44b12a72a9d03722522 (patch) | |
| tree | b0ce5c782592b5a2a6b7188195dea5ecbdd064f8 /debug_toolbar/views.py | |
| parent | 0b4fc3e4c30a645e4d7a706d890c74a82c88cb8c (diff) | |
| parent | b61c85f2f03d2e879319b15af238f6ee34fbe1a4 (diff) | |
| download | django-debug-toolbar-14245b5802d3a4b2a467c44b12a72a9d03722522.tar.bz2 | |
Merge pull request #447 from aaugustin/load-panels-contents-on-demand
Load the content of panels dynamically
Diffstat (limited to 'debug_toolbar/views.py')
| -rw-r--r-- | debug_toolbar/views.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/debug_toolbar/views.py b/debug_toolbar/views.py index 8b3e63c..21f4747 100644 --- a/debug_toolbar/views.py +++ b/debug_toolbar/views.py @@ -6,11 +6,30 @@ views in any other way is generally not advised. from __future__ import unicode_literals -from django.http import HttpResponseBadRequest +from django.http import HttpResponse, HttpResponseBadRequest from django.shortcuts import render +from django.utils.html import escape +from django.utils.translation import ugettext as _ from django.views.decorators.csrf import csrf_exempt from debug_toolbar.forms import SQLSelectForm +from debug_toolbar.toolbar.loader import get_saved_toolbar + + +def render_panel(request): + """Render the contents of a panel""" + toolbar = get_saved_toolbar(int(request.GET['toolbar_id'])) + if toolbar is None: + content = _("Data for this panel isn't available anymore. " + "Please reload the page and retry.") + content = "<p>%s</p>" % escape(content) + else: + panel_id = request.GET['panel_id'] + for panel in toolbar.panels: + if panel.dom_id() == panel_id: + content = panel.content() + break + return HttpResponse(content) @csrf_exempt |
