SHARE
TWEET

Untitled

a guest Jan 23rd, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from unicodedata import normalize
  2. data  = {}
  3. for qs in  queryset:
  4.       # remove os ascentos
  5.       target = normalize('NFKD', qs).encode('ASCII','ignore').decode('ASCII').title().strip()
  6.       data[target] = target
  7.  
  8. # orderna os items de um dict ou list  
  9. data_sorterd = sorted(data.items(), key=lambda kv: kv[1])
  10.  
  11. # order dict para manter a ordenação.
  12. return JsonResponse(OrderedDict((y, x) for x, y in data_sorterd))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top