stefanfoulis / django-phonenumber-field

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

graphql phone number serialize error #366

Closed kamranhossain closed 4 years ago

kamranhossain commented 4 years ago

In django-phonenumber-field when I use graphql(django-graphene, django-graphql-jwt) for authToken mutation. It gives me this error,

"message": "Object of type PhoneNumber is not JSON serializable".

Is there any way to work it with graphql or I need to go through the custom drf serializar for this issue. Thanks.

kamranhossain commented 4 years ago

I make the CharField rather than Phonenumberfield. It's work now.

brahimchougrani commented 4 years ago

I make the CharField rather than Phonenumberfield. It's work now.

hey, @kamranhossain I'm having the same problem where did you change the field?

kamranhossain commented 4 years ago

Hey, @brahimchougrani, I make CharField to a phone number in the model and add phone number validator. import the validator from phonenumber_field.validators.

from phonenumber_field.validators import validate_international_phonenumber
phone_number = models.CharField(
        max_length=15, validators=[validate_international_phonenumber], unique=True
    )