Thay vì phải viết
Trích tài liệu của Jinja:
Chú ý rằng 2 syntax này sẽ cho kết quả khác nhau nếu object có attribute trùng tên với key trong dict mà nó chứa.
HVN at FAMILUG dot ORG
adict['mykey']ta có thể viết
adict.mykey
Trích tài liệu của Jinja:
You can use a dot (.) to access attributes of a variable in addition to the standard Python__getitem__“subscript” syntax ([]).
The following lines do the same thing:
{{ foo.bar }}
{{ foo['bar'] }}
This is important if an object has an item and attribute with the same name. Additionally, theHếtattr()filter only looks up attributes.
HVN at FAMILUG dot ORG

Comments
Post a Comment