K
K
Konstantin Malyarov2018-05-29 10:44:39
Django
Konstantin Malyarov, 2018-05-29 10:44:39

What is the right way to include in a for loop?

<b-tabs>
                    </b-tab>
                    {% for department in user.departments.all %}
                        <b-tab title="{{ department.short_name }}">
                            {% include 'department/' + department.name + '/index.html' %}
                        </b-tab>
                    {% endfor %}
                </b-tabs>

How to insert the value of the department.name variable into an include?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2018-05-29
@Konstantin18ko

https://docs.djangoproject.com/en/2.0/ref/template...
You can pass additional context to the template using keyword arguments:

{% include "name_snippet.html" with person="Jane" greeting="Hello" %}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question