Skip to content

Instantly share code, notes, and snippets.

@DrMartiner
Created March 5, 2014 07:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DrMartiner/9362537 to your computer and use it in GitHub Desktop.
Save DrMartiner/9362537 to your computer and use it in GitHub Desktop.
Django template tag filter for phone display
# -*- 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:])
@mo-mughrabi
Copy link

try and catch would help if value index is not provided correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment