<form action="/hello/update/{{current.id}}" method="post">/hello/update/番号 というアドレスにフォームを送信していますね。こんな具合に、ID番号をURLにパラメータとして追加してアクセスできるようにしましょう。path('update/<int:id>', views.update, name='update'),これで、/update/番号 とアクセスをしたらupdateメソッドが呼び出されるようになりました。後は、views.py内にupdate関数を用意して、/hello/update/番号 へのアクセス処理を行うようにすればいいわけですね。※リストが表示されない場合
AddBlockなどの広告ブロックツールがONになっているとリストなどが表示されない場合があります。これらのツールをOFFにしてみてください。
{% load static %}
<html lang="ja">
<head>
<meta charset="utf-8">
<title>hello/update</title>
<link rel="stylesheet" type="text/css"
href="{% static 'hello/style.css' %}" />
</head>
<body>
<h1>hello/update</h1>
<p>{{msg}}</p>
<form action="/hello/update/{{current.id}}" method="post">
{% csrf_token %}
<table>
<tr>
<th><label for="name">name: </label></th>
<td><input id="name" type="text" name="name"
value="{{current.name}}"></td>
</tr>
<tr>
<th><label for="mail">mail: </label></th>
<td><input id="mail" type="text" name="mail"
value="{{current.mail}}"></td>
</tr>
<tr>
<th><label for="age">age: </label></th>
<td><input id="age" type="number" name="age"
value="{{current.age}}"></td>
</tr>
<tr>
<th></th>
<td><input type="submit" value="OK"></td>
</tr>
</table>
</form>
</body>
</html>
| << 前へ | 次へ >> |