Opened 17 years ago
Closed 10 years ago
#6285 closed New feature (wontfix)
Cutting up a list of objects into a table with a given number of columns
Reported by: | Purdea Andrei | Owned by: | Adrian Holovaty |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | Normal | Keywords: | feature_request |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | yes |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Cutting up a list of objects into a table with a given number of columns
Approaches that might be bad:
- it is not a good idea for the view to cut up the list, because the number of columns (N) is layout-related.
- useing divisibleby is somewhat low-level, you are implementing a for loop, in a template language that is supposed to be high-level
Proposal:
- to have a filter that will behave like this:
{% for row in objectlist|tablecols:3 %} <tr> {% for item in row %} <td> {{ item.content }} </td> {% endfor %} </tr> {% endfor %}
Attachments (1)
Change History (10)
comment:1 by , 17 years ago
Keywords: | feature_request added |
---|
comment:2 by , 17 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Triage Stage: | Unreviewed → Accepted |
comment:4 by , 16 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
What is the status of this ticket? It seems to have been accepted, but then closed by an anonymous user? It would be great to have this feature in Django.
by , 16 years ago
Attachment: | columns_rows_filters.diff added |
---|
Suggestion for filters to slice lists into rows and columns
comment:5 by , 14 years ago
Needs documentation: | set |
---|---|
Needs tests: | set |
Severity: | → Normal |
Type: | → New feature |
comment:8 by , 12 years ago
Status: | reopened → new |
---|
comment:9 by , 10 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Considering:
- how long this ticket has languished, with little demand,
- that it can easily be implemented in a third-part library,
- the current trend not to extend the template system further,
I'm going to close it.
Note:
See TracTickets
for help on using tickets.
I have template filters called
bunch
andbunchlong
in my personal Django projects, and they do exactly this. I'd be happy to add them as default filters; I'd argue they're useful enough to be in the defaults.