19๐
As a first debugging step: try to check the postgis template version manually, e.g. on the command-line connect to your database with psql test
, and query with select postgis_lib_version();
. This function should be defined in template_postgis and return some number. Example output:
$ psql test
psql (9.0.4)
Type "help" for help.
test=# select postgis_lib_version();
postgis_lib_version
---------------------
1.5.2
(1 row)
If an error occurs, you know the error is in the database.
40๐
Just add in your settings.py your right version of postgis :
POSTGIS_VERSION = (2, 0, 3)
- [Django]-Django 0.0.0.0:80; can't access remotely
- [Django]-How can I get MINIO access and secret key?
- [Django]-Django formset_factory vs modelformset_factory vs inlineformset_factory
10๐
The solution for me was to run the following in the postgres terminal:
psql database_name
database_name=# CREATE EXTENSION postgis;
If you get ERROR: relation "spatial_ref_sys" already exists
, run the following before CREATE EXTENSION postgis
:
drop table spatial_ref_sys;
drop table geometry_columns;
- [Django]-Django โ How to make a variable available to all templates?
- [Django]-How can I programmatically obtain the max_length of a Django model field?
- [Django]-Stack trace from manage.py runserver not appearing
3๐
And in case the previous select returns an error, it may be that one particular version of PostGIS was installed on that database, that you updated Postgres.app to a newer version, that bundles a newer version of PostGIS. For example, after the recent update from Postgis 2.0 to 2.1
In that case, you can make a migration after copying back some libraries, like described in this ticket
- [Django]-PermissionError: [Errno 13] Permission denied: '/manage.py'
- [Django]-Django modelform NOT required field
- [Django]-Django TextField and CharField is stripping spaces and blank lines
2๐
if you are using django_debug_toolbar
try to delete it or comment out debug_toolbar/utils/tracking/db.py
line 152 as suggested on https://github.com/django-debug-toolbar/django-debug-toolbar/issues/442
- [Django]-How to use Query Strings for filtering Querysets in Django?
- [Django]-Django: Where does "DoesNotExist" come from?
- [Django]-Django-rest-framework + django-polymorphic ModelSerialization