There are reasons. 1. It's handy and quick to type.
{% for x in lst %} {% if x.is_something %} {{ x }} {% endif %} {% endfor %} vs {% for x in lst if x.is_something %} {{ x }} {% endfor %} I really believe it is a common task. For me it is. 2. It's pythonic. It wouldn't be some Django-specific weird syntax. Python list comprehensions already work this way. {% for x in lst if x.is_something %} {{ x }} {% endfor %} [x for x in lst if x.is_something] 3. It looks better and makes the template code more readable. See reason 1 examples. -- Mikołaj Siedlarek On Tue, Mar 29, 2011 at 3:50 PM, Jacob Kaplan-Moss <ja...@jacobian.org>wrote: > Hi Mikołaj -- > > On Tue, Mar 29, 2011 at 8:45 AM, Mikołaj S. <mikos...@gmail.com> wrote: > > I've came up with an idea of improving default FOR template tag: > > {% for ... in ... %} > > By adding something similar to list comprehension syntax: > > {% for ... in ... if ... %} > > Can you give us some context for this request? What was the problem > you tried to solve that could only be solved by adding new syntax to > the template language? > > Without some context, this just sounds like adding syntax just because > we can, and I'm always going to be pretty against that. Simplicity is > a feature. > > Jacob > > -- > You received this message because you are subscribed to the Google Groups > "Django developers" group. > To post to this group, send email to django-developers@googlegroups.com. > To unsubscribe from this group, send email to > django-developers+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-developers?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.