Created
July 13, 2011 18:15
-
-
Save vbmendes/1080916 to your computer and use it in GitHub Desktop.
Django template debug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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