Question

I have written a templatetag to solve the repetitive creation of a special form. Got some problems with the logic, so i inserted pdb.set_trace() to get to its roots. But strangely this set_trace() never seems to be executed when i call the templatetag. The tag looks like this:

@register.tag('get_loop_form')
def get_loop_form(parser,token):

    import pdb;pdb.set_trace()

    #put some logic here

    return GetLoopForm()

And i simply call it in the template like this:

{% get_loop_form %}

Usually i get the chance to interact with the script at the line of the set_trace() when i do that. When i insert the set_trace() into the GetLoopForm.render method it works, but not when i insert it into get_loop_form. Why not?

edit: restarted the Django development server manually, which resulted in the code above working. I still do not understand why this happened.

Was it helpful?

Solution

Since it is a template tag, it might be cached on server start. Try to restart the server, that should solve the problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top