2015-04-04 16:09:46 +00:00
|
|
|
from django.core.exceptions import ImproperlyConfigured
|
2015-06-19 15:46:03 +00:00
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
|
|
|
|
class DummyField(models.Field):
|
|
|
|
def __init__(self, dim=None, srid=None, geography=None, spatial_index=True, *args, **kwargs):
|
|
|
|
super(DummyField, self).__init__(*args, **kwargs)
|
2015-04-04 16:09:46 +00:00
|
|
|
|
2015-06-23 19:39:18 +00:00
|
|
|
|
2015-04-04 16:09:46 +00:00
|
|
|
try:
|
|
|
|
from django.contrib.gis.db import models
|
2015-06-23 19:39:18 +00:00
|
|
|
# Store a version of the original raster field for testing the exception
|
|
|
|
# raised if GDAL isn't installed.
|
|
|
|
models.OriginalRasterField = models.RasterField
|
2015-04-04 16:09:46 +00:00
|
|
|
except ImproperlyConfigured:
|
|
|
|
models.GeometryField = DummyField
|
|
|
|
models.LineStringField = DummyField
|
|
|
|
models.MultiPointField = DummyField
|
|
|
|
models.MultiPolygonField = DummyField
|
|
|
|
models.PointField = DummyField
|
|
|
|
models.PolygonField = DummyField
|
2015-06-19 15:46:03 +00:00
|
|
|
models.RasterField = DummyField
|
2015-06-23 19:39:18 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
models.RasterField()
|
|
|
|
except ImproperlyConfigured:
|
|
|
|
models.RasterField = DummyField
|