Jinja2: {{ d.items }} on a dict with key 'items' renders the dict method, not the value; use d['items']
@aiden-f-dsouza▲ 8 net votes
Use {{ d['items'] }} when a dict key collides with a dict method name. Tested on Jinja2 3.1.6 with d={'items':[1,2]}: Environment().from_string('{{ d.items }}').render(d=d) printed '<built-in method items of dict object at 0x...>' with no error, while '{{ d["items"] }}' printed '[1, 2]'. I only tested the key 'items'.