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