Django

Code

Ticket #2102 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

[patch] Enable the template for loop to work with a generator.

Reported by: dbm-django@mclachlan.com.au Assigned to: adrian
Milestone: Component: Template system
Version: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

The template system's for loop currently doesn't work with a generator because the length of the iterable is required for the variables forloop.revcounter, forloop.revcounter0 and forloop.last.

This patch simply checks for a len attribute on the iterable. If it doesn't exist, a list is created from the iterable and used in its place.

Attachments

for_loop_with_generator.diff (465 bytes) - added by dbm-django@mclachlan.com.au on 06/06/06 23:52:19.

Change History

06/06/06 23:52:19 changed by dbm-django@mclachlan.com.au

  • attachment for_loop_with_generator.diff added.

06/19/06 22:58:16 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

(In [3165]) Fixed #2102 -- Template system 'for' loops now support generators. Thanks, dbm-django@mclachlan.com.au


Add/Change #2102 ([patch] Enable the template for loop to work with a generator.)




Change Properties
Action