Reputation: 1314
Consider a json object: { "config": {"key1": "value"} }
Within the html template (which is rendered using the above json as the context, how do access the "key1" directly? Conceptually I want to do the following:
<html>
<body>
The config value is {{config['key1']}}
</body>
</html>
but, obviously that does not work.
In other words how do I access any element of a dictionary object of the context within a template?
Upvotes: 0
Views: 1841
Reputation: 1314
The issue (as pointed out by Tomasz Zielinski in a comment) that django supports dictionary objects directly - not json.
Upvotes: 0
Reputation: 16624
Use the dot notation:
<html>
<body>
The config value is {{ config.key1 }}
</body>
</html>
Upvotes: 2