How to assign data returned to a variable or check data exist after calling django template filter


def sub_menu_count(value,arg): #




    return value[key]

Am using above code to return a list from the directory, and i need to check whether the returned list is empty or not from the template to do that.
This is the dictionary data.
{‘sub_menu_1’: [(2, ‘IPX Details’, 1, None, None), (4, ‘Signalling IPs’, 1, ‘master/IPX_signalling_ip.html’, None), (5, ‘Media IPs’, 1, ‘master/IPX_media_ip.html’, None)], ‘sub_menu_3’: []}

The below is how i call the filter tag,i dont know how to use if condition here

{{result_data.sub_menu |sub_menu_count:key}}

See the template if tag, and remember that in Python, an empty list evaluates to False.

I have updated the question, in template how can I use IF tag?

Please read the referenced documentation and give it a try. The first example should give you some ideas to work with.