100👍
✅
I normally go for:
<div class="item-image{% if foo %} own-image{% endif %}">...</div>
but switching out the entire div
tag may be more readable.
Either way I’d do the styling with another class, not with inline css.
5👍
I have added class on if condition by this way….
<li class="nav-item {% if app_url == '/' %} active{% endif %}">
- [Django]-Django: Get list of model fields?
- [Django]-In a Django QuerySet, how to filter for "not exists" in a many-to-one relationship
- [Django]-Django Get All Users
Source:stackexchange.com