[Django]-Django applying a style class based on a conditional

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.

👤second

5👍

I have added class on if condition by this way….

<li class="nav-item {% if app_url == '/' %} active{% endif %}">

Leave a comment