Opened 7 years ago

Closed 11 months ago

#6285 closed New feature (wontfix)

Cutting up a list of objects into a table with a given number of columns

Reported by: purdeaandrei Owned by: adrian
Component: Template system Version: master
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 taylanpince 6 years ago.
Suggestion for filters to slice lists into rows and columns

Download all attachments as: .zip

Change History (10)

comment:1 Changed 7 years ago by anonymous

  • Keywords feature_request added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 7 years ago by adrian

  • Owner changed from nobody to adrian
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

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 Changed 6 years ago by anonymous

  • Resolution set to fixed
  • Status changed from assigned to closed

comment:4 Changed 6 years ago by taylanpince

  • Resolution fixed deleted
  • Status changed from closed to 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.

Changed 6 years ago by taylanpince

Suggestion for filters to slice lists into rows and columns

comment:5 Changed 4 years ago by julien

  • Needs documentation set
  • Needs tests set
  • Severity set to Normal
  • Type set to New feature

comment:6 Changed 3 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:7 Changed 3 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:8 Changed 2 years ago by aaugustin

  • Status changed from reopened to new

comment:9 Changed 11 months ago by aaugustin

  • Resolution set to wontfix
  • Status changed from new to 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.
Back to Top