#34467: `Cycle` tag do not work with variables defined in `with`-tag.
-------------------------------------+-------------------------------------
Reporter: Prikalel | Owner: nobody
Type: Bug | Status: new
Component: Template | Version: 4.0
system | Keywords: cycle, with,
Severity: Normal | templates
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Here is the example:
{{{
{# context is simple dict with one key {A=["1", "2", "3"]} #}
{% with example_defined_variable="123" %}
{% for item in A %}
Current item: {{ item }}
Current cycle item: {% cycle example_defined_variable %}
{% endfor %}
Visible page.
{% endwith %}
}}}
As you can see I render this template using django 4.0.1 and context
containing 1 key "**A**" with the value of **["1", "2", "3"]** (that is
the list of strings).
Then I try to print the items of the list along with predefined value (see
**with**-tag).
The result must be like:
{{{
Current item: 1
Current cycle item: 123
Current item: 2
Current cycle item: 123
Current item: 3
Current cycle item: 123
Visible page.
}}}
But instead Im getting:
No named cycles in template. 'example_defined_variable' is not defined
That means that cycle-tag do not recognize **example_defined_variable** as
defined variable, BUT
on the
[https://docs.djangoproject.com/en/4.0/ref/templates/builtins/#cycle
documentation] page there is the note that you CAN use defined variables
in cycle-tag.
--
Ticket URL: <https://code.djangoproject.com/ticket/34467>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701875833921e-c613aec4-5b11-42bb-a253-a5b944f04dc4-000000%40eu-central-1.amazonses.com.