diff options
author | Primal Pappachan | 2012-03-20 11:22:17 +0530 |
---|---|---|
committer | Primal Pappachan | 2012-03-20 11:22:17 +0530 |
commit | 4f63e2eca861d597c1041bbf58c63ea4ea3e9a61 (patch) | |
tree | 5d02c4d86e7207a46f9a6da7a4af204c9a34a03c /allotter | |
parent | c78804ce5141565ee0e2a64e7f92aaaa126f30e0 (diff) | |
download | aloha-4f63e2eca861d597c1041bbf58c63ea4ea3e9a61.tar.gz aloha-4f63e2eca861d597c1041bbf58c63ea4ea3e9a61.tar.bz2 aloha-4f63e2eca861d597c1041bbf58c63ea4ea3e9a61.zip |
range filter template tag, basic complete page added
Diffstat (limited to 'allotter')
-rw-r--r-- | allotter/templatetags/__init__.py | 0 | ||||
-rw-r--r-- | allotter/templatetags/range_filter.py | 27 |
2 files changed, 27 insertions, 0 deletions
diff --git a/allotter/templatetags/__init__.py b/allotter/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/allotter/templatetags/__init__.py diff --git a/allotter/templatetags/range_filter.py b/allotter/templatetags/range_filter.py new file mode 100644 index 0000000..1ce43d8 --- /dev/null +++ b/allotter/templatetags/range_filter.py @@ -0,0 +1,27 @@ +##Credits : http://djangosnippets.org/snippets/1357/ + +from django.template import Library + +register = Library() + +@register.filter +def get_range( value ): + """ + Filter - returns a list containing range made from given value + Usage (in template): + + <ul>{% for i in 3|get_range %} + <li>{{ i }}. Do something</li> + {% endfor %}</ul> + + Results with the HTML: + <ul> + <li>0. Do something</li> + <li>1. Do something</li> + <li>2. Do something</li> + </ul> + + Instead of 3 one may use the variable set in the views + """ + return range( value ) + |