[Django]-Django Form Field to support US or International phone numbers?

5👍

How about:

https://github.com/stefanfoulis/django-phonenumber-field

Explaination From the site:

A international phone number field for django that uses
http://pypi.python.org/pypi/phonenumbers for validation.

from phonenumber_field.modelfields import PhoneNumberField
class MyModel(models.Model):
    name = models.CharField(max_length=255)
    phone_number = PhoneNumberField()
    fax_number = PhoneNumberField(null=True, blank=True)
👤leech

3👍

1👍

lazerscience’s answer is correct, but I want to give an alternative as you also asked for International Phone Numbers.

Just use a RegexField with a regular expression for the format you want, for the most types of phone numbers this can easily be googled. In fact, many local flavor fields are based on a RegexField.

But use the Local Flavor packages if it suits all your needs!

Leave a comment