Skip to content

Instantly share code, notes, and snippets.

@vbmendes
Created March 19, 2010 17:33
Show Gist options
  • Save vbmendes/337900 to your computer and use it in GitHub Desktop.
Save vbmendes/337900 to your computer and use it in GitHub Desktop.
from django.template import Library
register = Library()
@register.filter
def readable_list(lista):
lista = [unicode(item) for item in lista]
try:
return " e ".join(filter(None, [", ".join(lista[:-1]), lista[-1]]))
except IndexError:
return ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment