Getting 'DatabaseOperations' object has no attribute 'geo_db_type' error when doing a syncdb

前端 未结 9 1974
有刺的猬
有刺的猬 2020-12-01 08:43

I\'m attempting to run heroku run python manage.py syncdb on my GeoDjango app on Heroku, but I get the following error:

AttributeError: \'Databa

9条回答
  •  执念已碎
    2020-12-01 09:39

    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',
            }
        }
    

    Problem being 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

提交回复
热议问题