stefanfoulis / django-phonenumber-field

A django model and form field for normalised phone numbers using python-phonenumbers
MIT License
1.48k stars 314 forks source link

Algerian Phone Number is not accepted, throwing invalid #329

Closed Simouche closed 2 years ago

Simouche commented 5 years ago

When i enter my phone number "+213799136332" or any other valid algerian phone number, it doesn't accept it, throwing :

Enter a valid phone number (e.g. +12125552368).

i tried changing to diffrent PHONENUMBER_DB_FORMAT none of them worked, i tried with default region as DZ and entered a number with and without country code it throws:

Enter a valid phone number (e.g. 012 34 56 78) or a number with an international call prefix.

so please, any help is appreciated.

stefanfoulis commented 5 years ago

django-phonenumber-field delegates the actual number parsing to https://github.com/daviddrysdale/python-phonenumbers . Could you try to parse your phone number directly with that lower level library? That would help to narrow down if this is a django-phonenumber-field specific error or actually a problem in python-phonenumbers.

Simouche commented 5 years ago

here it is my friend, i think the issue is in django-phonenumber-field : >>> import phonenumbers >>> x = phonenumbers.parse("+213799136332",None) >>> x >>> PhoneNumber(country_code=213, national_number=799136332, extension=None, italian_leading_zero=None, number_of_leading_zeros=None, country_code_source=0, preferred_domestic_carrier_code=None) >>> y = phonenumbers.parse("0799136332","DZ") >>> y >>> PhoneNumber(country_code=213, national_number=799136332, extension=None, italian_leading_zero=None, number_of_leading_zeros=None, country_code_source=0, preferred_domestic_carrier_code=None) >>> x == y >>> True

samitnuk commented 5 years ago

@Simouche @stefanfoulis

I added PR #342 to show that the provided phone number is valid for both form and model. Please correct me if I missed something.

stefanfoulis commented 4 years ago

@Simouche are you still experiencing this issue?