LoginSignup
2
3

More than 5 years have passed since last update.

[Django] POSTフォームで送信した後に前のページにリダイレクトさせる

Posted at

環境
Python 3.5.0
Django 1.9.2

template.html
<form action="./?next={{ request.META.HTTP_REFERER }}" method="post">{% csrf_token %}
    ケーキの数: {{ cake_form.cake_num }}
    <input type="submit" value="送信">
</form>
views.py
from django.shortcuts import redirect

if 'next' in request.GET:
    return redirect(request.GET['next'])
2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3