Return to Snippet

Revision: 17551
at September 9, 2009 11:37 by vas3k


Initial Code
<select name="category" id="id_category">
<option value="" selected="selected">---------</option>
{% for item in categories %}
    {% ifequal item.parent_id 0 %}
        <optgroup label="{{ item.name }}">
            <option value="{{ item.id }}">{{ item.name }}</option>
            {% for subitem in categories %}
                {% ifequal subitem.parent_id item.id %}
                   <option value="{{ subitem.id }}">{{ subitem.name }}</option>
                {% endifequal %}
            {% endfor %}
        </optgroup>
    {% endifequal %}
{% endfor %}
</select>

Initial URL


Initial Description


Initial Title
Django Templates: Tree select option

Initial Tags
html, python, django

Initial Language
HTML