@register.filter
def sub_menu_count(value,arg): #
test_val=1
key="sub_menu_"+str(arg)
if(len(value[key])>0):
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 page.how 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}}