Getting 'DatabaseOperations' object has no attribute 'geo_db_type' error when doing a syncdb
The OP was using the GeoDjango buildpack, but in case anyone gets here using Geo buildpack and dj_database_url
like I was, in settings.py
don't forget the last line:
import dj_database_urlDATABASES['default'] = dj_database_url.config()DATABASES['default']['ENGINE'] = 'django.contrib.gis.db.backends.postgis'
UPDATE
dj_database_url
directly supports PostGIS. You can do without the last line in the code above if you can change your database URL to start with postgis
.
I got this error when trying to run tests with the test db set like so:
if 'test' in sys.argv: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': '_testdb', } }
The problem is that the sqlite3 DatabaseOperations
object doesn't have the attribute geo_db_type
(like the title of this post suggests).
My solution was to change the backend to the sqlite equivalent GIS engine:
'ENGINE': 'django.contrib.gis.db.backends.spatialite'
See the Django docs on GeoDjango installation for all the possible backends, with installation instructions: https://docs.djangoproject.com/en/3.0/ref/contrib/gis/install/#spatial-database