我安装了GDAL(使用homebrew
)和SQLite。我想创建一个带有PointField()的老师,它存储long和lat值,以了解它们的位置。后来我计划使用类似的东西添加按距离搜索的功能:
Teacher.objects.filter(location__distance_lte=(your_location,D(m=distance))).distance(your_location).order_by('distance')
from django.db import models
from django.contrib.gis.db import models as gis_models
from 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)
但是,当我运行服务器时,出现以下错误:
Unhandled exception in thread started by <function
check_errors.<locals>.wrapper at 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>
from django.contrib.gis.db import models as gis_models
File "/Applications/Anaconda/anaconda/envs/DjangoEnv/lib/python3.6/site-packages/django/contrib/gis/db/models/__init__.py",
line 3, in <module>
from 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>
from 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>
from 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>
from .fields import ( # NOQA
File "/Applications/Anaconda/anaconda/envs/DjangoEnv/lib/python3.6/site-packages/django/contrib/gis/forms/fields.py",
line 4, in <module>
from 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: Could not parse version info string "3.6.2-CAPI-1.10.2 4d2925d6"
答案 0 :(得分:0)