33👍
It sounds as though your Django settings aren’t quite right and that your database ENGINE
may be 'django.db.backends.postgresql'
, when it should be 'django.contrib.gis.db.backends.postgis'
. To confirm, run:
python manage.py shell
>>> from django.conf import settings
>>> settings.DATABASES
{'default': {'ATOMIC_REQUESTS': False,
'AUTOCOMMIT': True,
'CONN_MAX_AGE': 0,
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'HOST': '',
'NAME': 'mydatabase',
'OPTIONS': {},
'PASSWORD': '',
'PORT': '',
'TEST': {'CHARSET': None, 'COLLATION': None, 'MIRROR': None, 'NAME': None},
'TIME_ZONE': None,
'USER': ''}}
The above shows that I have one 'default'
database configured and it’s using the "postgis" engine (which is what we want).
Watch out for the use of the dj_database_url
package in your settings as this may be overriding the database settings from environment variables. Also watch for multiple databases other than "default" in the settings.
- Django Foreign Key: get related model?
- How to use ModelMultipleChoiceFilter?
- Django REST Framework: Validate before a delete
- Django annotate and count: how to filter the ones to include in count
Source:stackexchange.com