Debugging Django Template Tags
Sept. 21, 2013
Here's a cool bit of code snippet that I found from the web (original post here). I'm recording it here for my own easy reference without having to google it all the time. It describes a simple technique to debug Django templates using the python debugger - pdb.
@register.filter
def pdb(element):
import pdb; pdb.set_trace()
return element
Now, inside a template you can do
{{ template_var|pdb }}
and enter a pdb session (given you're running the local development server) where you can inspect element to your heart's content.
It's a very nice way to see what's happened to your object when it arrives at the template. :::