Posted By

vas3k on 09/09/09


Tagged

html python templates django


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

dainnet


Django Templates: Tree select option


 / Published in: HTML
 

  1. <select name="category" id="id_category">
  2. <option value="" selected="selected">---------</option>
  3. {% for item in categories %}
  4. {% ifequal item.parent_id 0 %}
  5. <optgroup label="{{ item.name }}">
  6. <option value="{{ item.id }}">{{ item.name }}</option>
  7. {% for subitem in categories %}
  8. {% ifequal subitem.parent_id item.id %}
  9. <option value="{{ subitem.id }}">{{ subitem.name }}</option>
  10. {% endifequal %}
  11. {% endfor %}
  12. {% endifequal %}
  13. {% endfor %}

Report this snippet  

You need to login to post a comment.