Package: django-debugtools
IntroductionThedebugtoolsmodule offers some easy to use debugging utilities to assist Django development.
It features:A template tag to print context.AXViewMiddlewarevariation to see whichviewandtemplatewas used to render a page.A panel fordjango-debug-toolbarto show whichviewandtemplatewas used to render a page.A jQuerydebug()function.InstallationFirst install the module, preferably in a virtual environment. It can be installed from PyPI:pip install django-debugtoolsOr the current folder can be installed:pip install .ConfigurationAdd the module to the installed apps:INSTALLED_APPS += (
    'debugtools',
)As of Django 1.9, either use{% load debugtools_tags %}or add the following to the settings:TEMPLATES=[{'BACKEND':'django.template.backends.django.DjangoTemplates','DIRS':[],'APP_DIRS':True,'OPTIONS':{'context_processors':['django.template.context_processors.debug','django.template.context_processors.request',# ...],'builtins':[# Add this section"debugtools.templatetags.debugtools_tags",# Add this line],},},]Or, when you use alocal.pysettings file:TEMPLATES[0]['OPTIONS']['builtins']+=["debugtools.templatetags.debugtools_tags",# enables {% print %}]FeaturesPrint Template TagIn Django templates, the following code can be used:{% print variable1 variable2 %}This will print out the specific variables, in case of{% print original %}:When no variables are given (e.g.{% print %}), all context variables are displayed:The template context variables are printed in a customizedpprint.pformatformat, for easy reading.
Note no{% load %}tag is needed; the{% print %}function is added to the template builtins for debugging convenience.Print Queries template tagFor convenience, there is also a{% print_queries %}tag,
based onhttp://djangosnippets.org/snippets/93/For more sophisticated debugging, you may want to use thedjango-debug-toolbarfor this job.Debug Toolbar PanelAdd the following settings to yourdjango-debug-toolbarconfiguration:DEBUG_TOOLBAR_PANELS = (
    'debug_toolbar.panels.versions.VersionsPanel',
    'debug_toolbar.panels.timer.TimerPanel',
    'debug_toolbar.panels.settings.SettingsPanel',
    'debug_toolbar.panels.headers.HeadersPanel',
    'debug_toolbar.panels.request.RequestPanel',
    'debug_toolbar.panels.sql.SQLPanel',
    'debug_toolbar.panels.staticfiles.StaticFilesPanel',
    'debugtools.panels.ViewPanel',    # Add this one
    'debug_toolbar.panels.templates.TemplatesPanel',
    'debug_toolbar.panels.cache.CachePanel',
    'debug_toolbar.panels.signals.SignalsPanel',
    'debug_toolbar.panels.logging.LoggingPanel',
    'debug_toolbar.panels.redirects.RedirectsPanel',
)jQuery debug printAdd the following to the page:<script type="text/javascript" src="{{ STATIC_URL }}debugtools/jquery.debug.js"></script>Now you can print the jQuery selector context to the console:$("#foo").children('li').debug().addClass('bar');This will print the matched<li>elements in the console, among with the current jQuery selector.
Optionally, a prefix can be included in thedebug()call:$("#foo").debug("at baz: ").addClass('bar');X-View MiddlewareAs alternative to thedjango-debug-toolbarpanel, you can also add theXViewMiddleware.
Add the following setting:INTERNAL_IPS = (
    '127.0.0.1',
)

MIDDLEWARE_CLASSES += (
    'debugtools.middleware.XViewMiddleware',
)All requests from the internal IP, or made by the admin user will have aX-Viewheader andX-View-Templateheader.
In the Firebug console, or Chrome web inspector, you can see which view and template handled the current request:The alternative templates are also displayed, in case the view allows the template to be overwritten with a different name.Print tag examplesFor example, when using the following code:{% print original %}

{% print inline_admin_formset %}

{% for inline_admin_form in inline_admin_formset %}
    {% print inline_admin_form %}
    {% print inline_admin_form.form.name %}
{% endfor %}It prints the context values, which helps to learn a lot about the template context:This makes it much easier to understand what the code provides to templates.