Closed kmartynski closed 1 year ago
There is no such option, because a regional phone number can be valid in different region, resulting in ambiguity.
I would rather recommend asking for phone numbers with a country selector (e.g. phonenumber_field.widgets.PhoneNumberPrefixWidget
), or a phone number in an international format (region=None
).
@francoisfreitag thank you for rapid response.
So if I understand correctly by the second recommendation I should only stick to:
PHONENUMBER_DEFAULT_FORMAT = "INTERNATIONAL"
class Client(models.Model):
phone = PhoneNumberField(region=None)
And remove
PHONENUMBER_DEFAULT_REGION = "PL"
Is that right? :)
Yes, if you don’t want to interpret national phone numbers in your region, leaving PHONENUMBER_DEFAULT_REGION
unspecified is the way to go. The system will then only accept phone numbers in an international format. To facilitate data entry for humans, you can use (or take inspiration from) the PhoneNumberPrefixWidget.
As for the format, INTERNATIONAL
is a good choice, it allows for international phone numbers, including phone extensions. https://django-phonenumber-field.readthedocs.io/en/stable/reference.html#phonenumber-db-format
Hi, I've been playing around with the library. I couldn't find any information around the web or in documentation. Supposedly I have a model in Django
settings.py
models.py
I'm not entirely sure if one might use many country codes, something like this:
Is there any option to accept phone numbers from many countries?