Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k 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 Reply

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...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...