For those that can accidentally add pdb into live commits, I can suggest this extension of #Koobz answer:
@register.filter
def pdb(element):
from django.conf import settings
if settings.DEBUG:
import pdb
pdb.set_trace()
return element