code: def get_service_url(request, redirect_to=None):
      
      if hasattr(django_settings, 'CAS_ROOT_PROXIED_AS'):
          service = django_settings.CAS_ROOT_PROXIED_AS + request.path
      else:
          protocol = get_protocol(request)
          host = request.get_host()
          service = urllib_parse.urlunparse(
              (protocol, host, request.path, '', '', ''),
          )
      if not django_settings.CAS_STORE_NEXT:
          if '?' in service:
              service += '&'
          else:
              service += '?'
          service += urllib_parse.urlencode({
              REDIRECT_FIELD_NAME: redirect_to or get_redirect_url(request)
          })
      return service
docs: Generates application django service URL for CAS