Django `if` statement isn't working? -


in template, added following debugging statement:

<script>   console.log("leaderboard? {{ client_settings.leaderboard_enabled }}"); </script> 

on console, see:

[14:09:20.026] "leaderboard? false" 

later in code, have following code:

{% if client_settings.leaderboard_enabled %} <button data-theme='a' onclick="$('.leaderboard').slidedown();">leaderboard</button> {% endif %} 

which think cause leaderboard button not appear... does! can see why is?

the python value boolean false stringified "false" capital f. since console statement has "false" lowercase f, value of client_settings.leaderboard_enabled string "false", interpreted boolean true.

the pythonic way change use true , false when setting leaderboard_enabled variable, instead of strings "true" , "false". if not feasible, change template test to:

{% if client_settings.leaderboard_enabled == "true" %} 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -