前提・実現したいこと
POSTで受け取ったデータを取り出したいです
発生している問題・エラーメッセージ
データを取り出そうとしても未定義になってしまいます
該当のソースコード
views.py
python
1def changeStatus(request): 2 if request.method != 'POST': 3 return HttpResponseRedirect(reverse('todos/index')) 4 status = request.POST.get('status') 5 todoId = request.POST.get('todoId') 6 # task = get_object_or_404(Task, pk=todoId) 7 return render(request, 'todos/changeStatus.html', {'todoId': todoId, 'status':status, 'a':request.POST})
index.html
python
1<script src="//code.jquery.com/jquery-1.11.1.min.js"></script> 2 3{% if taskList %} 4 <form action="{% url 'todos:changeStatus' %}" method="post">{% csrf_token %} 5 <h2>ToDo</h2> 6 <ul> 7 {% for task in taskList %} 8 {% if task.isToDo %} 9 <li class="js-taskId" data-task-id={{ task.getId }} > 10 <a href="{% url 'todos:detail' task.getId %}">{{ task.getName }}</a> 11 <input type="submit" class="js-submit" value="Doing"> 12 </li> 13 {% endif %} 14 {% endfor %} 15 </ul> 16 17 <h2>Doing</h2> 18 <ul> 19 {% for task in taskList %} 20 {% if task.isDoing %} 21 <li class="js-taskId" data-task-id={{ task.getId }}> 22 <a href="{% url 'todos:detail' task.getId %}">{{ task.getName }}</a> 23 <input type="submit" class="js-submit" value="Done"> 24 </li> 25 {% endif %} 26 {% endfor %} 27 </ul> 28 29 <h2>Done</h2> 30 <ul> 31 {% for task in taskList %} 32 {% if task.isDone %} 33 <li> 34 <a href="{% url 'todos:detail' task.getId %}">{{ task.getName }}</a> 35 <a href="{% url 'todos:delete' task.getId %}"><button type="button">削除</button></a> 36 </li> 37 {% endif %} 38 {% endfor %} 39 </ul> 40 <input type="hidden" id="status" value=""> 41 <input type="hidden" id="todoId" value=""> 42 </form> 43{% endif %} 44 45<a href="{% url 'todos:post' %}"><button type="button">追加</button></a> 46 47 48<script> 49 $(function(){ 50 $('.js-submit').on('click', function(){ 51 const STATUS = { 52 'Doing': 1, 53 'Done': 2 54 }; 55 let statusButtonVal = $('.js-submit').val(); 56 let taskId = $('.js-submit').closest('.js-taskId').attr('data-task-id'); 57 58 $('#todoId').val(taskId); 59 $('#status').val(STATUS[statusButtonVal]); 60 }); 61 }); 62</script>
補足情報(FW/ツールのバージョンなど)
formのhiddenに値が入っていることは確認できました
django: 3.1.7
python: 3.7.4

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。