2015-04-04 18:09:46 +02:00
|
|
|
from django.core.exceptions import ImproperlyConfigured
|
2015-06-19 17:46:03 +02: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 18:09:46 +02:00
|
|
|
|
2015-06-23 21:39:18 +02:00
|
|
|
|
2015-04-04 18:09:46 +02:00
|
|
|
try:
|
|
|
|
from django.contrib.gis.db import models
|
2015-06-23 21:39:18 +02: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 18:09:46 +02:00
|
|
|
except ImproperlyConfigured:
|
|
|
|
models.GeoManager = models.Manager
|
|
|
|
models.GeometryField = DummyField
|
|
|
|
models.LineStringField = DummyField
|
|
|
|
models.MultiPointField = DummyField
|
|
|
|
models.MultiPolygonField = DummyField
|
|
|
|
models.PointField = DummyField
|
|
|
|
models.PolygonField = DummyField
|
2015-06-19 17:46:03 +02:00
|
|
|
models.RasterField = DummyField
|
2015-06-23 21:39:18 +02:00
|
|
|
|
|
|
|
try:
|
|
|
|
models.RasterField()
|
|
|
|
except ImproperlyConfigured:
|
|
|
|
models.RasterField = DummyField
|