Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not work with the serializer field contains number #50

Closed
nyk510 opened this issue Feb 5, 2019 · 4 comments
Closed

Not work with the serializer field contains number #50

nyk510 opened this issue Feb 5, 2019 · 4 comments

Comments

@nyk510
Copy link

nyk510 commented Feb 5, 2019

Environment

  • Django==2.0

Abstract

We define some serializer field contains number like password1, the serializer can't detect field and raise required error.

Example

We define the endpoint to change password. The Serializer has two fields, i.e.

  • new_password1
  • new_password2

, then post to it with the body as

{
  "newPassword1": "hogehoge",
  "newPassword2": "hogehoge"
}

. We have required field error like

capture 2019-02-05 16 33 20

Downgrade djangorestframework-camel-case to 0.2.0, it works.

@nyk510 nyk510 changed the title Version>0.20 not work with some serializer field contains number Not work with the serializer field contains number Feb 5, 2019
@bunnyfly
Copy link

bunnyfly commented Feb 5, 2019

The recent upgrade to 0.2.0 -> 1.0.3 broke this exact form for me (django-rest-auth's rest_auth PasswordChangeView).

All other forms in my app seem to work, but if I append a number to fields in my own serializers, it also seems to break those and I can't seem to get them to work.

@insung151
Copy link
Contributor

insung151 commented Feb 7, 2019

Did you check underscoreize setting?

@nyk510
Copy link
Author

nyk510 commented Feb 7, 2019

@insung151 thanks for the wonderful comment !!
Is it different underscoreize default value before version==0.20 ...?

@roboxdev
Copy link

I had a similar problem when updated to 1.0.3

I've tried to POST this body. custom_earn_points_rate is JSONField

{
  "customEarnPointsRate":{
    "itemMultipliers":{},
    "categoryMultipliers":{
      "167": {"multiplier":1400}
    }
  }
}

And I got 16_7 as key instead of 167.
'no_underscore_before_number': True setting solved my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants