From: Michael Fladischer <FladischerMichael@fladi.at>
Date: Thu, 9 Feb 2023 08:20:42 +0000
Subject: Use local objects.inv in intersphinx mapping.

---
 docs/source/conf.py | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/docs/source/conf.py b/docs/source/conf.py
index 467567a..a18cf7d 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -21,6 +21,16 @@ extensions = [
 templates_path = ["_templates"]
 exclude_patterns = []
 html_theme = "sphinx_rtd_theme"
-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(
+        'django',
+        'https://docs.djangoproject.com/en/' + django.get_version() + '/',
+        '/usr/share/doc/python-django-doc/html/objects.inv'
+    )
+)
