1

When I pass a simple dict (myDict = {"key": "value"}) throught render to html, it creates an error as the html can't read the values of the dict ..

{{ myDict["key"] }} <!--- prompts an error-->

django.template.exceptions.TemplateSyntaxError: Could not parse the remainder: '['key']' from 'myDict['key']'

Why didn't I pass the value directly? Because my question is not about this particular example. I'm searching for a more effecient way to use in case I wanted to pass bigger dicts and avoid writing down a for loop and if conditions on every line.

The S.
  • 126
  • 1
  • 8

1 Answers1

0

You can try this in the template:

{{ myDict.key }}

As django uses dot notations for dictionaries for templates.

Ajay Lingayat
  • 1,465
  • 1
  • 9
  • 25