views:

90

answers:

2

Sorry if I am being a moron, but what happen with this if tag ?

view return:

return render_to_response('productos/por_estado.html', {'productos':productos}, 
                   context_instance=RequestContext(request))
#Im not returning 'estado' !

template:

{% if estado %}
{% block activos_active %}class="active"{% endblock %}
{% endif %}

template html result:

class="active"

:S

+4  A: 

Block tags cannot be set conditionally, arguably because they are part of template inheritance. I believe this was an explicit design decision by the Django developers. See this Django ticket as well as this other question on Stack Overflow.

Ryan Duffield
so I'll have to do something tricky to set "class="active"" of another way. thanks 4 your quickly reply.
panchicore
+1  A: 

One way to set class="active" could be just this

<div{% if estado %} class="active"{% endif %}>....</div>
vikingosegundo
Yes I did it like this ;) thx.
panchicore