如何将绝对URL传递给django函数并重定向到它?
def function(request):
back_url = request.META['HTTP_REFERER'] # example.com/home/?status=80&page=1
return redirect(back_url)
答案 0 :(得分:3)
你可以这样做:
def func(request):
url = request.META['HTTP_REFERER']
if request.META['QUERY_STRING']:
url += '?%s' % request.META['QUERY_STRING']
return redirect_to(request, url, **kwargs)