[Django] #34467: `Cycle` tag do not work with variables defined in `with`-tag.

1 view
Skip to first unread message

Django

unread,
Apr 6, 2023, 4:13:11 PM4/6/23
to django-...@googlegroups.com
#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.

Django

unread,
Apr 6, 2023, 4:15:23 PM4/6/23
to django-...@googlegroups.com
#34467: `Cycle` tag do not work with variables defined in `with`-tag.
-------------------------------------+-------------------------------------
Reporter: Prikalel | Owner: nobody
Type: Bug | Status: closed
Component: Template system | Version: 4.0
Severity: Normal | Resolution: duplicate
Keywords: cycle, with, | Triage Stage:
templates | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Prikalel):

* status: new => closed
* resolution: => duplicate


Comment:

Dublicate of
#34468

--
Ticket URL: <https://code.djangoproject.com/ticket/34467#comment:1>

Reply all
Reply to author
Forward
0 new messages