Opened 9 years ago
Closed 9 years ago
#26361 closed New feature (duplicate)
Template Filter for loop with range
Reported by: | Emett Speer | Owned by: | Emett Speer |
---|---|---|---|
Component: | Template system | Version: | 1.9 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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)))
Change History (2)
comment:1 by , 9 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 9 years ago
Resolution: | → duplicate |
---|---|
Status: | assigned → closed |
Type: | Uncategorized → New feature |
Note:
See TracTickets
for help on using tickets.
Duplicate of #13088. Please raise the idea on the DevelopersMailingList if you want to revisit the "wontfix" decision.