From: Michael Fladischer <FladischerMichael@fladi.at>
Date: Sun, 21 Aug 2016 13:17:22 +0200
Subject: use local objects.inv where possible

Upstream uses intersphinx mappings that fetch the objects.inv for python django
through HTTP from a remote host. Using the local objects.inv from python and
django enables the package to build without network connection.
---
 docs/conf.py | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/docs/conf.py b/docs/conf.py
index 8807ed2..8baec9f 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -269,11 +269,22 @@ texinfo_documents = [
 # texinfo_show_urls = 'footnote'
 
 
-# Example configuration for intersphinx: refer to the Python standard library.
-intersphinx_mapping = {
-    #'http://docs.python.org/': None,
-    "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/{v}'.format(
+            v='.'.join(map(str, django.VERSION[:2]))
+        ),
+        '/usr/share/doc/python-django-doc/html/objects.inv'
+    )
+)
 
 # autodoc settings
 autodoc_member_order = "groupwise"
