Added get_value_from_dict filter to obtain values from a dict in templates
This commit is contained in:
		
					parent
					
						
							
								a3c3a5cd2e
							
						
					
				
			
			
				commit
				
					
						3313dab485
					
				
			
		
					 1 changed files with 11 additions and 1 deletions
				
			
		| 
						 | 
					@ -22,3 +22,13 @@ def change_lang(context, lang=None, *args, **kwargs):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return "%s" % url
 | 
					    return "%s" % url
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@register.filter('get_value_from_dict')
 | 
				
			||||||
 | 
					def get_value_from_dict(dict_data, key):
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    usage example {{ your_dict|get_value_from_dict:your_key }}
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    if key:
 | 
				
			||||||
 | 
					        return dict_data.get(key)
 | 
				
			||||||
 | 
					    else :
 | 
				
			||||||
 | 
					        return None
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue