Created
August 22, 2012 16:07
-
-
Save juanique/3427063 to your computer and use it in GitHub Desktop.
A simple django template filter to strip accents to a string (based on http://stackoverflow.com/questions/517923/what-is-the-best-way-to-remove-accents-in-a-python-unicode-string )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django import template | |
| import unicodedata | |
| register = template.Library() | |
| def stripaccents(value, arg=""): | |
| if type(value) == str: | |
| return value | |
| return ''.join((c for c in unicodedata.normalize('NFD', value) if unicodedata.category(c) != 'Mn')) | |
| register.filter("stripaccents", stripaccents) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for what is the seven line? why do you return when is str?