code: def next_url(request):
      
      next = request.GET.get("next", request.POST.get("next", ""))
      host = request.get_host()
      return next if next and is_safe_url(next, host=host) else None
docs: Returns URL to redirect to from the ``next`` param in the request.