add a simple tag to convert a library id into a name
parent
223c005b86
commit
4d1bd51406
|
@ -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
|
||||
|
Loading…
Reference in New Issue