📜  django 在提交时不重定向 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:49.381000             🧑  作者: Mango

代码示例1
# 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)