environment Python 3.5.0 Django 1.9.2
template.html
<form action="./?next={{ request.META.HTTP_REFERER }}" method="post">{% csrf_token %}
Number of cakes: {{ cake_form.cake_num }}
<input type="submit" value="Send">
</form>
views.py
from django.shortcuts import redirect
if 'next' in request.GET:
return redirect(request.GET['next'])
Recommended Posts