I have a view that retrieves a JSON file like this:
json_lang = requests.get('path/to/file.json').json()
return render(request, "chat/chatroom.html", {'jsonLang': json.dumps(json_lang)})
Let's say the json file is structured somewhat like this:
{
"en": {
"action.send": "Send",
"chat.joined": "joined the chatroom",
"chat.left": "left the chatroom",
...
}
If I try to access one of those strings in a template like this {{ jsonLang.en.chat.joined }}
I get an empty output.
Other methods, like trying to access it like this jsonLang["en"]["chat.joined"]
result in an error:
TemplateSyntaxError at /chat/
Could not parse the remainder: '["en"]["chat.joined"]' from 'json_lang.["en"]["chat.joined"]'
What's the correct method to do this?