Accessing dictionary by key in Django template

The Django template language supports looking up dictionary keys as follows:

{{ json.key1 }}

See the template docs on variables and lookups.

The template language does not provide a way to display json[key], where key is a variable. You can write a template filter to do this, as suggested in the answers to this Stack Overflow question.

Leave a Comment