今天用Django寫網站中的註冊部分的時候遇到這個問題了,記錄下如何改正。
因爲我用到了Django自帶的用戶系統的profile擴展功能,在註冊的時候寫入數據庫需要注意:
user = User.objects.create_user(username, email, password1)
user.save()
#用戶擴展信息
# profile = UserProfile()
# profile.yyId = yyid
# profile.yyName = yyname
# profile.mainPlayer = mainplayer
profile = UserProfile(user=user,yyId=yyid,yyName=yyname,mainPlayer=mainplayer)
profile.save()
註釋掉的部分應該註釋下面的那句,具體分析有空寫