If I do that:
var importance_not_matched = {{item.this_article_importance}} <= article_importance;
It seems to work but in my IDE (Pycharm) I have errors: "Expression expected" on the "<=" and "underterminated statment" on the final ";"
I'm using flask, item.this_article_importance is an int
I solved my issue by changing to:
year_not_matched = {{item.this_article_year <= article_year}};
I don't understand why it's better yet though
Depending on the type of value that is {{ item.this_article_importance }}
you may have to use filter |safe
, so that django does not escape it.
Something like this:
var importance_not_matched = {{ item.this_article_importance|safe }} <= article_importance;
You can verify that both variables really have the desired value, even the type, to ensure where the error comes from.
var this_article_importance = {{ item.this_article_importance|safe }};
console.log(typeof(this_article_importance), this_article_importance);
It's hard to know more without more information. You can review this question where the topic is discussed.
I solved my issue by changing to:
year_not_matched = {{item.this_article_year <= article_year}};
I don't understand why it's better yet though
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.