Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

flask - jinja2 filter causing dict object has no attribute error

Why is this throwing the errors below? This is in the .html file for presentation to the user

{% for year,data in data_inputs.data_set.items() %}
    {{ data.data_point }} \ WORKS; output is 10
    {{ data.data_point|int }} \ Throws "dict object has no attribute 'data_point' error"
    {{ data.data_point - 2 }} \ Throws "dict object has no attribute 'data_point' error"
{% endfor %}
question from:https://stackoverflow.com/questions/65858369/jinja2-filter-causing-dict-object-has-no-attribute-error

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Need to check all items; one of them did indeed not have the right data_point - though was coming out as blank until you try and perform an operator on it subsequently...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...