HassenPy / django-pdb

Gives you `manage.py runserver --pdb` and `manage.py test --pdb`
394 stars 61 forks source link

New template filter to explore a template variable into pdb #11

Closed Psycojoker closed 12 years ago

Psycojoker commented 12 years ago

Usage:

{% load template_filters %}

{{ variable|pdb }}

Drop you in a ipdb with the variable if ipdb is installed otherwise in pdb.

sfllaw commented 12 years ago

I'm also unsure whether this is the right way to go about it.

I understand that you'd want to debug a template on the fly, but it occurs to me that debugging just a variable isn't very useful. Perhaps we're aiming for something more generalized that lets you stop rendering halfway through a template?

Psycojoker commented 12 years ago

Weill, I found that often useful, especially because I'm often carrying around complex objects in my templates (maybe not the best practice) and being able to understand why the hell one of them isn't working as expected save me plenty of time.

This said, you might be on a cool idea, I don't see for the moment how this could be done.

sfllaw commented 12 years ago

Ah. Now that you've explained it, the use-case is more obvious. Perhaps the documentation should show a more complex object being inspected? Like a QuerySet?

I suppose the |pdb filter would also be useful in debugging other filters as well. Such as when you chain |pdb|custom_filter so that you can step through to the next one?

Psycojoker commented 12 years ago

Indeed for debuging a filter, didn't saw that usecase. I've updated the README in this regards and with informations on the possible usecase of this filter.