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

posted @ 2018-10-12 17:52  HPCM  阅读(2742)  评论(0编辑  收藏  举报