add a simple tag to convert a library id into a name

pull/1/head
eric 2013-12-15 00:24:04 -05:00
parent 223c005b86
commit 4d1bd51406
2 changed files with 19 additions and 0 deletions

View File

View File

@ -0,0 +1,19 @@
import unicodedata
from django.template.base import Library
from .. import models
register = Library()
@register.filter()
def libname(value):
"""
returns library name .
"""
try:
vl = long( value )
lib = models.Library.objects.get(pk=vl)
return lib.__unicode__()
except models.Library.DoesNotExist:
return value