Commits

Andrew Godwin committed 68d4398

Only enable GIS if there's a supported backend.

Comments (0)

Files changed (1)

south/modelsinspector.py

 from django.utils.functional import Promise
 from django.contrib.contenttypes import generic
 from django.utils.datastructures import SortedDict
-from django.contrib.gis.db.models.fields import GeometryField
+
+try:
+    from django.contrib.gis.db.models.fields import GeometryField
+    has_gis = True
+except Exception: # Almost certainly because they're using an unsupported backend.
+    has_gis = False
 
 NOISY = True
 
             "blank": ["blank", {"default": True}],
         },
     ),
-    (
-        (GeometryField, ),
-        [],
-        {
-            "srid": ["srid", {"default": 4326}],
-            "spatial_index": ["spatial_index", {"default": True}],
-            "dim": ["dim", {"default": 2}],
-        },
-    ),
 ]
 
+if has_gis:
+    introspection_details += [
+        (
+            (GeometryField, ),
+            [],
+            {
+                "srid": ["srid", {"default": 4326}],
+                "spatial_index": ["spatial_index", {"default": True}],
+                "dim": ["dim", {"default": 2}],
+            },
+        ),
+    ]
+
 # Similar, but for Meta, so just the inner level (kwds).
 meta_details = {
     "db_table": ["db_table", {"default_attr_concat": ["%s_%s", "app_label", "module_name"]}],
         return True
     # Check it's a core field (one I've written for)
     module = field.__class__.__module__
-    return module.startswith("django.db") or module.startswith("django.contrib.gis") or module.startswith("django.contrib.localflavor") or module.startswith("django.contrib.contenttypes.generic")
+    return module.startswith("django.db") or (has_gis and module.startswith("django.contrib.gis")) or module.startswith("django.contrib.localflavor") or module.startswith("django.contrib.contenttypes.generic")
 
 
 def matching_details(field):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.