[Django] #26361: Template Filter for loop with range

89 views
Skip to first unread message

Django

unread,
Mar 16, 2016, 12:18:22 AM3/16/16
to django-...@googlegroups.com
#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.

Django

unread,
Mar 16, 2016, 7:08:42 AM3/16/16
to django-...@googlegroups.com
#26361: Template Filter for loop with range
---------------------------------+--------------------------------------
Reporter: the-kid89 | Owner: the-kid89
Type: Uncategorized | Status: assigned

Component: Template system | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by the-kid89):

* status: new => assigned
* needs_better_patch: => 0
* owner: nobody => the-kid89
* needs_tests: => 0
* needs_docs: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/26361#comment:1>

Django

unread,
Mar 16, 2016, 7:31:18 AM3/16/16
to django-...@googlegroups.com
#26361: Template Filter for loop with range
---------------------------------+--------------------------------------
Reporter: the-kid89 | Owner: the-kid89
Type: New feature | Status: closed

Component: Template system | Version: 1.9
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by timgraham):

* status: assigned => closed
* type: Uncategorized => New feature
* resolution: => duplicate


Comment:

Duplicate of #13088. Please raise the idea on the DevelopersMailingList if
you want to revisit the "wontfix" decision.

--
Ticket URL: <https://code.djangoproject.com/ticket/26361#comment:2>

Reply all
Reply to author
Forward
0 new messages