I have to include variables while styling django templates using Bootstrap.
<div class="card mb-2 text-white bg-info">
The info part will be changed for each card accordingly. Is there any way similair to this ?
<div class="card mb-2 text-white bg-{card.category}">
card
is from the respective model.
Please help
Putting a condition can be helpful:
<div class="card mb-2 text-white bg-
{% if card.category==value1 %} class A
{% elif card.category==value2 %} class B
{% else %} class C
{% endif %}
">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.