Giter Club home page Giter Club logo

debug-inspector-panel's Introduction

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.panels.inspector 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.

debug-inspector-panel's People

Contributors

angvp avatar santiagobasulto avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.