📅  最后修改于: 2022-03-11 14:45:49.381000             🧑  作者: Mango
# stay on same page you're currently on after form submission
from django.http import HttpResponseRedirect
def yourView(request):
if request.method == 'POST':
# Your model and form save code here
return redirect(request.META.get('HTTP_REFERER', 'index'))
return HttpResponseRedirect(request.path_info)