#27126: Use `namedtuple` in result of `{% regroup %}`
------------------------------------------------+------------------------
               Reporter:  bmispelon             |          Owner:  nobody
                   Type:  Cleanup/optimization  |         Status:  new
              Component:  Template system       |        Version:  1.10
               Severity:  Normal                |       Keywords:
           Triage Stage:  Unreviewed            |      Has patch:  1
    Needs documentation:  0                     |    Needs tests:  0
Patch needs improvement:  0                     |  Easy pickings:  0
                  UI/UX:  0                     |
------------------------------------------------+------------------------
 Currently, `{% regroup %}` returns a list of dictionaries with two key
 (`grouper` and `list`).

 I propose chaning that to return a namedtuple with the same fields.

 This should be backwards-compatible because attribute access and key
 access inside template uses the same syntax.

 The added benefit would be that you could now write:
 {{{#!django
 {% regroup places by country as country_list %}

 <ul>
 {% for country, cities in country_list %}
     <li>{{ country }}
     <ul>
         {% for city in cities %}
           <li>{{ city.name }}: {{ city.population }}</li>
         {% endfor %}
     </ul>
     </li>
 {% endfor %}
 </ul>

 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27126>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.698476c9a7525d2dcdd62b873f6b1676%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to