django-phonenumber-field icon indicating copy to clipboard operation
django-phonenumber-field copied to clipboard

Unexpected behavior when used with ArrayField

Open angelkenneth opened this issue 7 years ago • 2 comments

Provided we have the model:

from django.contrib.postgres.fields import ArrayField
from django.db.models import Model
from phonenumber_field.modelfields import PhoneNumberField

class Foo(Model):
    contact = PhoneNumberField()
    contacts = ArrayField(PhoneNumberField(), default=list)

Then run the following:

Foo.objects.create(contact="+639171234567", contacts=["+639171234567"])
foo = Foo.objects.get()

Accessing the variables, one could expect the following:

foo.contact
>>> PhoneNumber(country_code=63, national_number=9171234567, ...)
foo.contacts
>>> [ PhoneNumber(country_code=63, national_number=9171234567, ...) ]

However, foo.contacts returns a list of strings:

foo.contact
>>> PhoneNumber(country_code=63, national_number=9171234567, ...)
foo.contacts
>>> ['+639171234567']

angelkenneth avatar Feb 21 '18 07:02 angelkenneth

@GheloAce thanks for reporting this

stefanfoulis avatar Feb 21 '18 08:02 stefanfoulis

Reproduced this issue with django-phonenumber-field 7.0.0 and Django 4.1.1.

francoisfreitag avatar Sep 09 '22 15:09 francoisfreitag