Opened 17 years ago
Closed 17 years ago
#9521 closed (duplicate)
cycle templatetag is nondeterministic
| Reported by: | Grzegorz Lukasik | Owned by: | nobody | 
|---|---|---|---|
| Component: | Template system | Version: | 1.0 | 
| Severity: | Keywords: | cycle nondeterministic templatetag | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no | 
| Needs tests: | no | Patch needs improvement: | no | 
| Easy pickings: | no | UI/UX: | no | 
Description
It can bite you when for example you are coloring rows in your table in some pattern. After refresh you may get different coloring (if you use the sample compiled template, which is not true for default django template processing).
from django.template import Context, Template
t = Template("{% cycle 1 2 3 %}")
t.render(Context())
u'1'
t.render(Context())
u'2'
t.render(Context())
u'3'
t.render(Context())
u'1'
  Note:
 See   TracTickets
 for help on using tickets.
    
Formatted code:
>>> from django.template import Context, Template >>> t = Template("{% cycle 1 2 3 %}") >>> t.render(Context()) u'1' >>> t.render(Context()) u'2' >>> t.render(Context()) u'3' >>> t.render(Context()) u'1'