From: Carsten Schoenert <c.schoenert@t-online.de>
Date: Fri, 10 Sep 2021 17:15:38 +0200
Subject: Use local inventory for intersphinx

The upstream way is to fetch the interspinx inventary by https from
docs.djangoproject.com.
Using instead the packages stuff from python3-django-doc.

This patch is basicaly completely taken from python-testfixtures and was
written by Michael Fladischer <FladischerMichael@fladi.at>.

Forwarded: not-needed
---
 docs/conf.py | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/docs/conf.py b/docs/conf.py
index 7dac581..088faad 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -1,3 +1,4 @@
+import django
 import os
 import sys
 
@@ -25,13 +26,27 @@ latex_documents = [
     ),
 ]
 
-intersphinx_mapping = {
-    "django": (
-        "https://docs.djangoproject.com/en/stable/",
-        "https://docs.djangoproject.com/en/stable/_objects/",
+def check_object_path(key, url, path):
+    if os.path.isfile(path):
+        return {key: (url, path)}
+    return {}
+
+intersphinx_mapping = {}
+intersphinx_mapping.update(check_object_path(
+    'python',
+    'https://docs.python.org/{v}/'.format(
+        v='.'.join(map(str, sys.version_info[0:2]))
     ),
-    "python": ("https://docs.python.org/3", None),
-}
+    '/usr/share/doc/python{v}/html/objects.inv'.format(
+        v='.'.join(map(str, sys.version_info[0:2]))
+    )
+))
+
+intersphinx_mapping.update(check_object_path(
+    'django',
+    'https://django.readthedocs.org/en/latest/',
+    '/usr/share/doc/python-django-doc/html/objects.inv'
+))
 
 if not on_rtd:
     import sphinx_rtd_theme
