#26361: Template Filter for loop with range
---------------------------------+--------------------
Reporter: the-kid89 | Owner: nobody
Type: Uncategorized | Status: new
Component: Template system | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------
I propose a filter be added to make a template for loop from a range. This
could look something like this {% for _ in 5|range %}. It seems to me that
something like this should already be in the template language for Django
already. This would be added to "django/template/defaultfilters.py"
The code for something like this could be as follows
{{{
@register.filter(is_safe=False)
@stringfilter
def range(value):
"""
Returns a list the length of the value
Will cast a string to an int
"""
return list(range(int(value)))
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26361>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.ff439d55d296ae0ae19a4afb9bfa2d91%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.