Yura YuLife

ITエンジニアの覚え書き。

2015-04-04から1日間の記事一覧

Djangoでフォーム内でクリックされたボタンによって異なる処理を行う

タイトルの通り、同一フォーム内でクリックしたボタンによって異なる処理を行いたい場合は以下のように書きます。 hoge.html <form action="{% url 'hoge.views.some_view' %}" method="post"> {% csrf_token %} <input type="text" name="hoge" value=""> ... <input type="submit" name="button_1" value="ボタン1"> <input type="submit" name="button_2" value="ボタン2"> </form> v…