diff --git a/biscuit/core/templatetags/data_helpers.py b/biscuit/core/templatetags/data_helpers.py index 342ff5ceafdaded10e1977cf99ef7609311e257c..5267472ba6a7d2e9588b80fcd1ec0c44ce414885 100644 --- a/biscuit/core/templatetags/data_helpers.py +++ b/biscuit/core/templatetags/data_helpers.py @@ -6,5 +6,14 @@ register = template.Library() @register.filter -def get_dict(value: Dict[Any, Any], arg: Any) -> Any: - return value.get(arg, None) +def get_dict(value: Any, arg: Any) -> Any: + """Gets an attribute of an object dynamically from a string name""" + + if hasattr(value, str(arg)): + return getattr(value, arg) + elif hasattr(value, 'has_key') and value.has_key(arg): + return value[arg] + elif str(arg).isnumeric() and len(value) > int(arg): + return value[int(arg)] + else: + return None