Login

Snippets by ke1g

Snippet List

MultiSelect checkbox iterator template filter

Sometimes you want more rendering control than common widgets give you. We wrote this, for example, to allow rendering the checkboxes of a multi select field with checkbox widget, as multiple columns. Place this in the templatetags subdirectory of an app you are loading (be sure it has a __init__.py file), and load it something like this (you may want to shorten the name): {% load checkboxiterator_filter %} Then you can say something like: {% for checkbox in form.categories|checkboxiterator %} {# other code #}{{ checkbox }}{# other code #} {% endfor %} where form.categories is a multiple select field (no doubt this technique could be applied to radio buttons and a single select field). The filter does use some internal interfaces, but may well still work on newer Django version.

Read More

ke1g has posted 1 snippet.