Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Serializing "complex" field returns None instead of the value since 3.4 #4272

Closed
Labels
Milestone
@aaugustin

Description

@aaugustin

(Not a great title — I hope the description will clarify.)

Steps to reproduce

First:pip install django-phonenumber-field

With the following model and serializer:

fromdjango.db.modelsimportModelfromphonenumber_field.modelfieldsimportPhoneNumberFieldfromrest_framework.serializersimportModelSerializerclassPhoneModel(Model):number=PhoneNumberField()classPhoneSerializer(ModelSerializer):classMeta:model=PhoneModelfields= ['number']

Expected behavior

This test used to pass (until version 3.3.3):

deftest_phone_serializer():phone=models.PhoneModel(number='+33610293847')data=models.PhoneSerializer(phone).dataassertdata['number']=='+33610293847'

Actual behavior

The test fails (since version 3.4) with:

    def test_phone_serializer():        phone = models.PhoneModel(number='+33610293847')        data = models.PhoneSerializer(phone).data>       assert data['number'] == '+33610293847'E       assert None == '+33610293847'

Analysis

I bisected this regression to9c996d7.

As far as I can tell, DRF used to get the string representation of the field and no longer does.

(Pdb) phone.numberPhoneNumber(country_code=33, national_number=610293847, extension=None, italian_leading_zero=None, number_of_leading_zeros=None, country_code_source=1, preferred_domestic_carrier_code='')(Pdb) str(phone.number)'+33610293847'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp