The Official Kountr Blog

Just another WordPress.com weblog

Intuition Can Lead You Astray

leave a comment »

Myers and Briggs would consider me an ENTP. I rely on my N quite a bit. I just ran into a painful to debug issue with Django templates thanks to my oh so helpful N.

I had an ‘if’ clause and I put a  ‘block’ inside it. I only want to update the block if a certain condition is met. Intuitively I could read {% if … %} {% block … %} … {% endblock %}{% endif %}. I guess the precedence comes into play, the block gets read no matter what, so here I was debuging the variables in the if clause only to find out they were being ignored.

The solution is to invert the block and the if tags. I guess if you wanted to set the contents of the block on a conditional but have it remain as an ancestor template had set it, then you could use the {{ block.super }} tag to import that value.

The bigger picture solution is keep intuition in check when debugging. I suspect the counter point it true for all you Myers-Briggs S’. Keep you N and your S in balance.

Written by Michael Artemiw

May 21, 2008 at 6:06 am

Posted in Uncategorized

Leave a comment