Robert
Robert

Reputation: 481

How to add Conditional CSS class based on Python If statement

How do you add a conditional CSS class based on a Python if statement in the following example to show the has-success has-feedback form element?

<div class="form-group {% if not error_username %} has-success has-feedback {% endif %}">

Upvotes: 27

Views: 20295

Answers (1)

SumanKalyan
SumanKalyan

Reputation: 1761

Write if condition this way.

<div class="form-group {{'has-success has-feedback' if not error_username }}">

Upvotes: 53

Related Questions