Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#1461 closed defect (wontfix)

[patch] regroup tag doesn't resolve grouper variable

Reported by: Russell Cloran <russell@…> Owned by: adrian
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: UI/UX:

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@…> 9 years ago.
regroup_real.patch (1.2 KB) - added by Russell Cloran <russell@…> 9 years ago.
Whoops, forgot one of the changes I made in the previous patch.

Download all attachments as: .zip

Change History (3)

Changed 9 years ago by Russell Cloran <russell@…>

Changed 9 years ago by Russell Cloran <russell@…>

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

comment:1 Changed 9 years ago by adrian

  • Resolution set to wontfix
  • Status changed from new to closed

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