Comments (8)
In my very first post I wrote exact version of python and django-phonenumber-field used 😉. To be even more specific:
Successful cases
python2
- python 2.7.12
- Django 2.0.6
- django-phonenumber-field 2.0.0
- phonenumberslite 8.9.9
python3
- python 3.6.5
- Django 2.0.6
- django-phonenumber-field 2.0.0
- phonenumberslite 8.9.9
Unsuccessful cases
python2
- python 2.7.12
- Django 1.11.13
- django-phonenumber-field 1.0.0
- phonenumbers 8.9.9
python3
- python 3.6.5
- Django 2.0.6
- django-phonenumber-field 1.0.0
- phonenumbers 8.9.9
My bottom line is it not related with version of python or Django or phonenumbers*. It was a change between django-phonenumber-field version 1.0.0 and 1.1.0. Therefore there is noting to fix.
I think there is no reasonable output for those inputs. This library is very lenient... perhaps too much. I would rise ValueError
on the very beginning not allowing such inputs at all.
from django-phonenumber-field.
This is a standalone script not a copy-paste solution for your problem. If you use django-phonenumber-field in version 1.0.0 you get AssertionError
regardless python version run. Using anything more up to date e.g. recent version 2.0.0 solves your problem.
To test my theses please just launch your python interpreter and copy-paste this sample code. If you find I'm wrong please attach output of this script and add result of pip freeze
command.
from django-phonenumber-field.
Yes I have the same issue, it seems this was not resolved.
from django-phonenumber-field.
Please consider following script:
import phonenumbers
from django.conf import settings
from phonenumber_field.phonenumber import PhoneNumber, to_python
settings.configure(PHONENUMBER_DEFAULT_REGION='PH')
assert str(to_python('none')) == '+NoneNone'
assert str(to_python('None')) == '+NoneNone'
assert str(to_python('9581093')) == '+639581093'
assert str(PhoneNumber.from_string(phone_number='123')) == '+63123'
I've run it successfully on both python 2.7.12 and python 3.6.5 with django-phonenumber-field 2.0.0 installed. So I couldn't reproduce your issue.
from django-phonenumber-field.
@neequole and @amateja with which version of django-phonenumber-field have you each tested?
And besides the possible inconsistency between python versions: What do we want as a reasonable output for those inputs?
from django-phonenumber-field.
HI @amateja
Where did you modify this is it inside your library or I need to create a new class.
import phonenumbers
from django.conf import settings
from phonenumber_field.phonenumber import PhoneNumber, to_python
settings.configure(PHONENUMBER_DEFAULT_REGION='PH')
assert str(to_python('none')) == '+NoneNone'
assert str(to_python('None')) == '+NoneNone'
assert str(to_python('9581093')) == '+639581093'
assert str(PhoneNumber.from_string(phone_number='123')) == '+63123'
from django-phonenumber-field.
HI, I had this figured out,
got confused where to place that, but again through reading /testing was able to solved it.
Thank you for this!
from django-phonenumber-field.
Glad I could help. Cheers!
from django-phonenumber-field.
Related Issues (20)
- Remove check for .mo files
- Form field does not auto-detect region from international number HOT 2
- Italian translations incomplete HOT 5
- Usage with django ninja HOT 5
- Multiple countrycodes in `PhoneNumberField` HOT 3
- Make the model/formfield region kwarg the default selection in PhoneNumberPrefixWidget HOT 1
- Validation error with wrong locale HOT 1
- bug in python 3.10 HOT 1
- Extension information is lost during serialization HOT 8
- [Question] Best way to generae US phonenumber for testing HOT 1
- validate_international_phonenumber does not validate correctly at some cases HOT 1
- Pydantic Serialization HOT 1
- Use Django's "normal" validation, not hardcoded in __init__() HOT 9
- Turkmenistan phone numbers has been updated HOT 1
- The valid phonenumber is not accepted by this package HOT 1
- 0493 prefix invalid numbet Australia HOT 1
- Handling of special (non-geo) phone numbers
- python-phonenumbers should be a requirement HOT 1
- django-phonenumber-field[phonenumberslite] requires phonenumbers on migration HOT 1
- Support numbers as phone numbers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-phonenumber-field.