code: def get_next_url(request, redirect_field_name):
      
      next_url = request.GET.get(redirect_field_name)
      if next_url:
          kwargs = {
              'url': next_url,
              'require_https': import_from_settings(
                  'OIDC_REDIRECT_REQUIRE_HTTPS', request.is_secure())
          }
  
          hosts = list(import_from_settings('OIDC_REDIRECT_ALLOWED_HOSTS', []))
          hosts.append(request.get_host())
          kwargs['allowed_hosts'] = hosts
  
          is_safe = is_safe_url(**kwargs)
          if is_safe:
              return next_url
      return None
docs: Retrieves next url from request
  
      Note: This verifies that the url is safe before returning it. If the url
      is not safe, this returns None.
  
      :arg HttpRequest request: the http request
      :arg str redirect_field_name: the name of the field holding the next url
  
      :returns: safe url or None