前提・実現したいこと
セッションに保存された数字をprintしたい
発生している問題・エラーメッセージ
session is saved for 2 Internal Server Error: /something3 Traceback (most recent call last): File "/home/a/.local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/home/a/.local/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/a/.local/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/a/Dropbox/!Django/something/views.py", line 64, in shiharai_saisoku_moushitatesho_3 print('print_fee is ' + str(request.session.get['print_fee'])) TypeError: 'method' object is not subscriptable [23/Aug/2020 02:04:31] "POST /something3 HTTP/1.1" 500 74671
該当のソースコード
Python
1def something(request): 2 content = { 3 'title': 'Page3/6', 4 'form': something3(), 5 } 6 if request.method == 'POST': 7 request.session['case_name'] = request.POST['billing_occurrence_name'] 8 request.session['number_of_dependant'] = request.POST['number_of_dependant'] 9 request.session['print_fee'] = request.POST['print_fee'] 10 request.session['sending_fee'] = request.POST['sending_fee'] 11 request.session['notification_fee'] = request.POST['notification_fee'] 12 request.session['making_and_sending_fee'] = request.POST['making_and_sending_fee'] 13 if request.POST['qualification_fee'] == 0: 14 request.session['qualification_fee'] = 0 15 print(request.session.get('qualification_fee')) 16 else: 17 request.session['qualification_fee'] = request.POST['qualification_fee'] 18 print(request.session.get('qualification_fee')) 19 print('session is saved for 2') 20 print('print_fee is ' + str(request.session.get['print_fee'])) 21 print('sending_fee is ' + str(request.session.get['sending_fee'])) 22 print('notification_fee is' + str(request.session.get['notification_fee'])) 23 print('making_and_sending is ', str(request.session.get['making_and_sending'])) 24 print('qualification_fee is ', str(request.session.get['qualification_fee'])) 25 return render(request, './something4.html', content)
試したこと
printしたい値をin(),str()に変更してみましたが、エラーが出ます。
補足情報(FW/ツールのバージョンなど)
Python 3.8.2
Django3.0.6
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。