Opened 17 years ago

Closed 11 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)

columns_rows_filters.diff (2.1 KB ) - added by Taylan Pince 16 years ago.
Suggestion for filters to slice lists into rows and columns

Download all attachments as: .zip

Change History (10)

comment:1 by anonymous, 17 years ago

Keywords: feature_request added

comment:2 by Adrian Holovaty, 17 years ago

Owner: changed from nobody to Adrian Holovaty
Status: newassigned
Triage Stage: UnreviewedAccepted

I have template filters called bunch and bunchlong 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.

comment:3 by anonymous, 16 years ago

Resolution: fixed
Status: assignedclosed

comment:4 by Taylan Pince, 16 years ago

Resolution: fixed
Status: closedreopened

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 Taylan Pince, 16 years ago

Attachment: columns_rows_filters.diff added

Suggestion for filters to slice lists into rows and columns

comment:5 by Julien Phalip, 14 years ago

Needs documentation: set
Needs tests: set
Severity: Normal
Type: New feature

comment:6 by Aymeric Augustin, 13 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:7 by Aymeric Augustin, 13 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:8 by Aymeric Augustin, 12 years ago

Status: reopenednew

comment:9 by Aymeric Augustin, 11 years ago

Resolution: wontfix
Status: newclosed

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.
Back to Top