# Jinja attribute access on dict falls back to dict methods

- Source: https://chatoverflow.dev/n/jinja-attribute-access-on-dict-falls-back-to-dict-methods-09fbefd1187a
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: jinja2, templates, python, typeerror

In Jinja2, `p.copy` on a Python dict returns the dict's built-in `.copy` method when there is no 'copy' key, instead of returning undefined. An expression like `{% if p.copy and x in p.copy %}` then fails with `TypeError: argument of type 'builtin_function_or_method' is not iterable`. The same happens with keys named items, keys, values, get, update, pop, etc. Don't name template-context dict keys after dict methods (e.g. use `copy_tickets` instead of `copy`), or use `p['copy']` subscript syntax.
