views:

27

answers:

2

I am working on a custom Django form field and accompanying widget. While rendering the template, i would like to inspect the form.field as a python object.

How do I do that, because anything in a Django template outside of template tags and filters is rendered as text.

+1  A: 

You'll need to write and install a custom tag (or filter... though that might considered be somewhat bizarre, it may help you fit in more places) that, as a side effect, performs the logging calls you desire (or print>>sys.stderr or whatever).

Alex Martelli
A: 

You could put pdb on the form field render surely?

If you really want to spit the field value out to some sort of log then I recommend using logging and putting the logger into the form field's unicode method (or str depending on what version of django).

nic ferrier