Konstantin18ko
@Konstantin18ko
Стоматолог

Как правильно сделать include при цикле for?

<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>

Как в include вставить значение переменной department.name?
  • Вопрос задан
  • 127 просмотров
Решения вопроса 1
sim3x
@sim3x
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" %}
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы