Created
March 5, 2014 07:08
-
-
Save DrMartiner/9362537 to your computer and use it in GitHub Desktop.
Django template tag filter for phone display
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
# -*- coding: utf-8 -*- | |
from django import template | |
register = template.Library() | |
@register.filter() | |
def phone(value): | |
return '+%s %s %s %s %s' % (value[0], | |
value[1:4], | |
value[4:7], | |
value[7:9], | |
value[9:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
try and catch would help if value index is not provided correctly