AttributeError: Got AttributeError when attempting to get a value for field `password2` on serializer ` UserSerializer`...


Error_msg:

AttributeError: Got AttributeError when attempting to get a value for field `password2` on serializer `        UserSerializer`.
        The serializer field might be named incorrectly and not match any attribute or key on the `User` instance.
        Original exception text was: 'User' object has no attribute 'password2'.
        ERROR basehttp 124 "POST /users/ HTTP/1.1" 500 20189
        pydev debugger: process 22712 is connecting

问题:

  序列化器字段读写设置出错

解决:

  serializer中没有write_only_fields关键字, 需要在字段中加write_only=True


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM