code: def is_external_url(self, url, site_url):
          
          url_splitted = urlsplit(url)
          if not url_splitted.netloc:
              return False
          return url_splitted.netloc != urlsplit(site_url).netloc
docs: Check if the URL is an external URL.