Opened 19 years ago

Closed 19 years ago

Last modified 17 years ago

#1461 closed defect (wontfix)

[patch] regroup tag doesn't resolve grouper variable

Reported by: Russell Cloran <russell@…> Owned by: Adrian Holovaty
Component: Template system Version:
Severity: minor Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi,

I'm not sure if this will be seen as a defect, but it certainly is irritating me :)

When regroup'ing, eg:

{% regroup object_list|dictsort:groupby by groupby as grouped %}

The variable groupby is resolved in the filter, but not in the "by" clause of the regroup tag. This means that it is impossible to group by a value learned at runtime.

Patch attached which fixes the problem... Grouping by a predetermined string would now be done like this:

{% regroup object_list|dictsort:groupby by "foo" as grouped %}

NOTE: This changes the specification of the regroup tag.

(PS, I'm using magic-removal)

Attachments (2)

regroup.patch (782 bytes ) - added by Russell Cloran <russell@…> 19 years ago.
regroup_real.patch (1.2 KB ) - added by Russell Cloran <russell@…> 19 years ago.
Whoops, forgot one of the changes I made in the previous patch.

Download all attachments as: .zip

Change History (3)

by Russell Cloran <russell@…>, 19 years ago

Attachment: regroup.patch added

by Russell Cloran <russell@…>, 19 years ago

Attachment: regroup_real.patch added

Whoops, forgot one of the changes I made in the previous patch.

comment:1 by Adrian Holovaty, 19 years ago

Resolution: wontfix
Status: newclosed

I'm not sure I see how this solution would work...The groupby parameter is applied as an attribute-lookup on each object in object_list, so I don't see how it's useful to use that dynamically.

Note: See TracTickets for help on using tickets.
Back to Top