django - PointField() Not Working correctly in GeoDjango -
i have gdal (using homebrew
) , sqlite installed. create teacher pointfield() stores long , lat values, know location. later plan on adding ability search distance using like:
teacher.objects.filter(location__distance_lte=(your_location,d(m=distance))).distance(your_location).order_by('distance')
models.py
from django.db import models django.contrib.gis.db import models gis_models django.contrib.auth.models import user class teacher(models.model): user = models.foreignkey(user, unique=true) location = gis_models.pointfield() availability = models.booleanfield(default=false)
however, when run server, following error:
unhandled exception in thread started <function check_errors.<locals>.wrapper @ 0x111c619d8> traceback (most recent call last): file "/applications/anaconda/anaconda/envs/djangoenv/lib/python3.6/site-packages/django/utils/autoreload.py", line 227, in wrapper fn(*args, **kwargs) file "/applications/anaconda/anaconda/envs/djangoenv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run autoreload.raise_last_exception() file "/applications/anaconda/anaconda/envs/djangoenv/lib/python3.6/site-packages/django/utils/autoreload.py", line 250, in raise_last_exception six.reraise(*_exception) file "/applications/anaconda/anaconda/envs/djangoenv/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise raise value.with_traceback(tb) file "/applications/anaconda/anaconda/envs/djangoenv/lib/python3.6/site-packages/django/utils/autoreload.py", line 227, in wrapper fn(*args, **kwargs) file "/applications/anaconda/anaconda/envs/djangoenv/lib/python3.6/site-packages/django/__init__.py", line 27, in setup apps.populate(settings.installed_apps) file "/applications/anaconda/anaconda/envs/djangoenv/lib/python3.6/site-packages/django/apps/registry.py", line 108, in populate app_config.import_models() file "/applications/anaconda/anaconda/envs/djangoenv/lib/python3.6/site-packages/django/apps/config.py", line 202, in import_models self.models_module = import_module(models_module_name) file "/applications/anaconda/anaconda/envs/djangoenv/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) file "<frozen importlib._bootstrap>", line 978, in _gcd_import file "<frozen importlib._bootstrap>", line 961, in _find_and_load file "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked file "<frozen importlib._bootstrap>", line 655, in _load_unlocked file "<frozen importlib._bootstrap_external>", line 678, in exec_module file "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed file "/users/gr/desktop/pycharmprojects/djangowebsite/users/models.py", line 2, in <module> django.contrib.gis.db import models gis_models file "/applications/anaconda/anaconda/envs/djangoenv/lib/python3.6/site-packages/django/contrib/gis/db/models/__init__.py", line 3, in <module> django.contrib.gis.db.models.aggregates import * # noqa file "/applications/anaconda/anaconda/envs/djangoenv/lib/python3.6/site-packages/django/contrib/gis/db/models/aggregates.py", line 1, in <module> django.contrib.gis.db.models.fields import extentfield file "/applications/anaconda/anaconda/envs/djangoenv/lib/python3.6/site-packages/django/contrib/gis/db/models/fields.py", line 3, in <module> django.contrib.gis import forms, gdal file "/applications/anaconda/anaconda/envs/djangoenv/lib/python3.6/site-packages/django/contrib/gis/forms/__init__.py", line 3, in <module> .fields import ( # noqa file "/applications/anaconda/anaconda/envs/djangoenv/lib/python3.6/site-packages/django/contrib/gis/forms/fields.py", line 4, in <module> django.contrib.gis.geos import geosexception, geosgeometry file "/applications/anaconda/anaconda/envs/djangoenv/lib/python3.6/site-packages/django/contrib/gis/geos/__init__.py", line 18, in <module> has_geos = geos_version_info()['version'] >= '3.3.0' file "/applications/anaconda/anaconda/envs/djangoenv/lib/python3.6/site-packages/django/contrib/gis/geos/libgeos.py", line 196, in geos_version_info raise geosexception('could not parse version info string "%s"' % ver) django.contrib.gis.geos.error.geosexception: not parse version info string "3.6.2-capi-1.10.2 4d2925d6"
this known issue, has been fixed , rolled out in django v1.11.5.
if can't wait 1.11.5 or don't want run on dev branch, can go previous version of geos:
brew switch geos 3.6.1
Comments
Post a Comment