Skip to content

santiagobasulto/debug-inspector-panel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

17e9a37 · Aug 27, 2018

History

14 Commits
Aug 19, 2012
Jul 16, 2012
Aug 10, 2012
Aug 27, 2018
Aug 19, 2012
Aug 19, 2012

Repository files navigation

This project has been abandoned. There's an updated version by @hgezim here: https://github.com/hgezim/debug-inspector-panel

Inspector Panel

So long as I can put print statements in the code, and can read it thoroughly, I can usually find the bugs.

Joshua Bloch, about his techniques for debugging programs (extracted from Coders at work)

Inspector panel is intended to retrieve information about variables when developing Django applications.

The panel must be used with django-debug-toolbar.

Motivation

Have you found yourself doing this all the time?:

def my_view(request):
    my_var = some_third_party_function()
    print my_var
    print type(my_var)
    #...

Well, I used to do that a lot. So, I decided to write this simple panel.

The idea is to use just one function debug and get lots of information. Here's an example of a real Django App:

from inspector_panel.panels.inspector import debug

def index(request):
    latest_poll_list = Poll.published.all().order_by('-pub_date')[:5]
    debug(latest_poll_list)  # Just add this line
    return render_to_response('polls/index.html', {'latest_poll_list': latest_poll_list})

You get first some information in the Debug Toolbar:

Debug Toolbar panel

And you can optionally get the same info in the console:

Console debug

Installation

$ pip install git+git://github.com/santiagobasulto/debug-inspector-panel

Add the panel to the DEBUG_TOOLBAR_PANELS settings variable:

DEBUG_TOOLBAR_PANELS = (
    ...
    'inspector_panel.panels.inspector.InspectorPanel',
    ...
)

Add inspector_panel to your INSTALLED_APPS

INSTALLED_APPS = (
    # ... More Apps ... #
    'debug_toolbar',
    'inspector_panel'
)

Use

Just import the debug function:

from inspector_panel import debug

and use it to debug whatever you want:

debug([1, 2, 3])
debug(Poll)
debug(Poll.objects.all())

def my_function():
    print "Hello World"

debug(my_function)

Optionally you can disable console logging:

debug([1, 2, 3], console=False)

Important!

This panel is NOT a replacement for other more complete tools as python logging and pdb.

License

See LICENSE on project root.

About

A django-debug-toolbar panel to get information about certain variables.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published