Giter Club home page Giter Club logo

Comments (8)

amateja avatar amateja commented on August 16, 2024 3

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.

amateja avatar amateja commented on August 16, 2024 1

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.

Shazam14 avatar Shazam14 commented on August 16, 2024

Yes I have the same issue, it seems this was not resolved.

from django-phonenumber-field.

amateja avatar amateja commented on August 16, 2024

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.

stefanfoulis avatar stefanfoulis commented on August 16, 2024

@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.

Shazam14 avatar Shazam14 commented on August 16, 2024

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.

Shazam14 avatar Shazam14 commented on August 16, 2024

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.

amateja avatar amateja commented on August 16, 2024

Glad I could help. Cheers!

from django-phonenumber-field.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.