This is a customized version of the default for template tag which takes an optional {% else %} clause that will be displayed if the given array is empty.
from django.template import *
t1 = Template("""
{% load mytags %}
{% for athlete in athlete_list %}
{{ athlete }}
{% else %}
No athlete in list!
{% endfor %}
""")
c1 = Context(
{'athlete_list':
['me ...
I’ve written a couple of things recently talking about useful things to be aware of when you’re putting together the URL configuration for a Django application — one covering a pitfall you should watch out for with regular expressions and one touching on the utility of the “url” tag and the “permalink” decorator, and the “reverse” utility — but you can never have too much useful information about URL configuration, because for a lot of ...
Read full entry and comments