Skip to content

Instantly share code, notes, and snippets.

@JustAyush
Created August 11, 2019 11:43
Show Gist options
  • Save JustAyush/17dcb515acc68fc31fe592e1bd423ea0 to your computer and use it in GitHub Desktop.
Save JustAyush/17dcb515acc68fc31fe592e1bd423ea0 to your computer and use it in GitHub Desktop.
from django import template
import json
import operator
register = template.Library()
@register.filter
def lowerCase(value):
try:
value = value.replace("\'", "\"")
value = json.loads(value)
maxValue = max(value.items(), key=operator.itemgetter(1))[0]
except:
maxValue = value
return maxValue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment