In a django template, if I have a key within the context dictionary assocoated with another dictionary (a nested dictionary), I know how to itterate over it (how to iterate through dictionary in a dictionary in django template?) but I need to find a value by key.
like {{ nested_dictionary['key'] }}
But I'm guessing not exactly that...
Filters could be used, but is there a better way?
Yes, if you have a nested dictionary in your view i.e.:
...
dashTable = {'Key0':{'Key1':{'Key2':{'Key3':5}}}}
context = {'dashTable':dashTable,}
return render(request, 'template.html', context)
Then you would be able to call your nested dictionary when passed through as context with:
{{ dashTable.Key0.Key1.Key2.Key3 }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With