Code

Opened 17 months ago

Closed 17 months ago

Last modified 17 months ago

#19890 closed Cleanup/optimization (fixed)

ifchanged tag renders the nodelist_true part twice

Reported by: vdboor Owned by: nobody
Component: Template system Version: 1.4
Severity: Normal Keywords: sprint2013
Cc: chrismedrela 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

The {% ifchanged %}foo{% endifchanged %} node renders the contents twice;

  • First to compare it with the previous value
  • The second time to return the rendered output.

This was discovered while fixing 15849

Attachments (1)

19890-fix-double-ifchanged-rendering.patch (2.2 KB) - added by vdboor 17 months ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 17 months ago by vdboor

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

The patch can be applied after merging #15849

comment:2 Changed 17 months ago by jacob

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 17 months ago by bpeschier

  • Keywords sprint2013 added

comment:4 Changed 17 months ago by chrismedrela

  • Cc chrismedrela added
  • Triage Stage changed from Accepted to Ready for checkin

The patch seems good to me. I simplified the test and added pull request: https://github.com/django/django/pull/832.

comment:5 Changed 17 months ago by Christopher Medrela <chris.medrela@…>

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

In 636c45fc58bcc19d7669a739ccd05ff475381f48:

Fixed #19890 -- ifchanged templatetag rendered its content twice

The content of ifchanged template tag was rendered twice: first time, to
compare it with the previous value and the second time, to return the
rendered output.

comment:6 Changed 17 months ago by Preston Holmes <preston@…>

In e369dc28075b4331c125494fe7bd73855d73a0ce:

Merge pull request #832 from chrismedrela/ticket19890

Fixed #19890 -- ifchanged templatetag rendered its content twice

comment:7 Changed 17 months ago by Julien Phalip <jphalip@…>

In ae2a8bb4569e569d0cc2cd8173443862418d3698:

Fixed a test that was failing in Python 3.
The issue was that as of Python 3, the generators' next()
method becomes __next(). Thanks Alex Gaynor for noticing that.
Refs #19890.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.