Skip to content

Instantly share code, notes, and snippets.

@vbmendes
Created July 13, 2011 18:15
Show Gist options
  • Save vbmendes/1080916 to your computer and use it in GitHub Desktop.
Save vbmendes/1080916 to your computer and use it in GitHub Desktop.
Django template debug
# -*- coding: utf8 -*-
"""
Template tag to stop template rendering to debug.
It's useful to know what is in the context.
Just put this file in a templatetags module inside your app and
insert this code in your templates where you want to debug:
{% load pdbdebug %}{% pdbdebug %}
"""
try:
import ipdb as pdb
except ImportError:
import pdb
from django.template import Library, Node
register = Library()
class DebugNode(Node):
def render(self, context):
pdb.set_trace()
return ''
@register.tag
def pdbdebug(parser, token):
return DebugNode()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment