Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Include statement doesn't work inside for loop #338

Open
wesselvanderlinden opened this issue Sep 26, 2023 · 2 comments
Open

Include statement doesn't work inside for loop #338

wesselvanderlinden opened this issue Sep 26, 2023 · 2 comments
Assignees
Labels

Comments

@wesselvanderlinden
Copy link

wesselvanderlinden commented Sep 26, 2023

When I use include statements outside of for loops, they seem to work, but when I move the include statement over to the for loop it errors out.

My code:

    <form>
        {% for fieldName in object.Fields %}
            {% include "field/text.django" with name="TEST" %}
        {% endfor %}
    </form>

And the error I get:

failed to render: [Error (where: checkForValidIdentifiers)] context-key '' (value: '<schema.Type Value>') is not a valid identifier

If I move the include statement like below, I get no error and the 'field/text.django' template gets rendered correctly:

    <form>
         {% include "field/text.django" with name="TEST" %}

        {% for fieldName in object.Fields %}

        {% endfor %}
    </form>

Are include statements not supposed to work inside for loops, or am I doing something wrong?

For reference, this is the contents of field/text.django:

<label for="{{ name }}">
    {{ name }}
    <input type="text" id="{{ name }}" name="{{ name }}" />
</label>
@the-maldridge
Copy link

Just to add some color, this for sure worked in v4, I have yet to run a bisect to see exactly where it stopped working.

@flosch flosch self-assigned this Oct 21, 2024
@flosch
Copy link
Owner

flosch commented Oct 21, 2024

Thanks for raising this issue. If you find the respective commit, please let me know.

@flosch flosch added the bug label Oct 21, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants