Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我如何将绝对 url 传递给 django 函数并重定向到它?
def function(request): back_url = request.META['HTTP_REFERER'] # example.com/home/?status=80&page=1 return redirect(back_url)
你可以做:
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)