[PYTHON] [Django] Redirect to previous page after submitting with POST form

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

[Django] Redirect to previous page after submitting with POST form
[Django] How to redirect unlogged-in users to the login page
Post to slack with Python 3
I can't log in to the admin page with Django3
Convert PIL format images read from form with Django to base64 format
Steps to develop Django with VSCode
[Django] How to test Form [TDD]
Common html to rent with Django
How to get started with Django
Easily post to twitter with Python 3
How to authenticate with Django Part 2
How to authenticate with Django Part 3
How to do arithmetic with Django template
Step notes to get started with django
CRUD POST with Nuxt & Django REST Framework
How to automatically generate API document with Django REST framework & POST from document screen
Instantly convert Model to Dictionary with Django and initialize Form at explosive speed