Template context debugger with (I)Pdb

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
from django.template import Library, Node

register = Library()

try:
    import ipdb as pdb
except ImportError:   
    import pdb

class PdbNode(Node):
    def render(self, context):
        pdb.set_trace()
        return ''
@register.tag
def pdb_debug(parser, token):
    return PdbNode()

More like this

  1. Updated - Template context debugger with (I)Pdb by dnordberg 3 years, 9 months ago
  2. Template Context Debugger with Pydev by showell 3 years, 11 months ago
  3. HTML5 filter for XXS by ronnie 2 years ago
  4. "Open file in Textmate"-support in werkzeug debugger browser view by grandfatha 1 year, 3 months ago
  5. Load response.content in browser (for debugging) by tin_nqn 1 year ago

Comments

showell (on June 4, 2009):

This is an interesting idea. I am using pydev now, and I'm relatively new to that environment, and I am wondering if there's a similar way to hook into pydev's debugger.

#

jsandell (on June 5, 2009):

showell: I don't know if this has changed, as I haven't used Eclipse for a couple of years, but from what I can recall all you have to do is make sure the pydev directory is in your Django application's python path. i.e., put this:

import sys; sys.path.insert(0, '/path/to/pydev')

below the line:

from django.template import Library, Node

in this snippet.

Hope this helps.

(Note, I bet it'll work with WinPdb as well)

#

showell (on June 17, 2009):

See http://www.djangosnippets.org/snippets/1571/ for a pydev variation. jsandell, it seems you don't need to actually add pydev to the path if you launch your app using pydev's debugger.

#

Vilma29Church (on January 1, 2012):

Don't you acknowledge that this is the best time to receive the credit loans, which would help you.

#

(Forgotten your password?)