django-phonenumber-field
django-phonenumber-field copied to clipboard
Unexpected behavior when used with ArrayField
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']
@GheloAce thanks for reporting this
Reproduced this issue with django-phonenumber-field 7.0.0 and Django 4.1.1.