Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use international format if region differs from default #331

Conversation

st4lk
Copy link

@st4lk st4lk commented Sep 24, 2019

My use case:

  1. "US" region by default
  2. "National" format by default
  3. but in case of non "US" phone number - use INTERNATIONAL format

1, 2 works fine:

PHONENUMBER_DEFAULT_REGION = 'US'
PHONENUMBER_DEFAULT_FORMAT = 'NATIONAL'

But if I'll submit an international phone number (e.g. "+79261234567") into django admin form for PhoneNumberField field - error will be shown that phone number is incorrect.
Internally, such PhoneNumber instance will be created:

PhoneNumber(country_code=1, national_number=89261234567, extension=None, italian_leading_zero=None, number_of_leading_zeros=None, country_code_source=20, preferred_domestic_carrier_code='')

Which doesn't look correct: instead of +7 region, +1 was applied.

This patch tends to fix it.

@ghost
Copy link

ghost commented Sep 24, 2019

DeepCode Report (#3bca6b)

DeepCode analyzed this pull request.
There are no new issues.

Base automatically changed from master to main January 17, 2021 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants