新しいエントリを作成しない場合、エントリが既に存在する場合はデータベースを更新しようとしています。
def saveprofile(request):
location = request.POST['location']
email = request.POST['email']
if request.user.is_authenticated():
userprofile = UserProfiles(user=request.user)
if userprofile:
userprofile.location=location
userprofile.email=email
userprofile.save()
return render_to_response('profile.html',{'pfields':userprofile})
else:
userprofile = UserProfiles(user=request.user, location=location, email=email)
userprofile.save()
return render_to_response('profile.html',{'pfields':userprofile})
投げてる
(1062、「キー 'user_id' のエントリ '15' が重複しています」)