[Django]-How to access the dynamic key in Django template?

6👍

You cannot access it that way, djangos template language does not allow that. See this post that @BearBrown mentioned in his comment.

You could write your own custom template filter
like this answer shows:

from django.template.defaulttags import register
...
@register.filter
def get_item(dictionary, key):
    return dictionary.get(key)
👤Ralf

Leave a comment