#1461 closed defect (wontfix)
[patch] regroup tag doesn't resolve grouper variable
Reported by: | 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)
Change History (3)
by , 19 years ago
Attachment: | regroup.patch added |
---|
by , 19 years ago
Attachment: | regroup_real.patch added |
---|
comment:1 by , 19 years ago
Resolution: | → wontfix |
---|---|
Status: | new → 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.
Whoops, forgot one of the changes I made in the previous patch.