我可以makemigrations
,但不能migrate
架构。
的django-geoposition == 0.3.0
Django的== 1.11.5
python3.6.2
在x86_64-apple-darwin14.5.0上的PostgreSQL 9.6.5,由Apple LLVM版本7.0.0(clang-700.1.76)编译,64位
import environ
env = environ.Env()
...
DATABASES = {
'default': env.db("DATABASE_URL", default="postgres://postgres:postgres@localhost:5432/soken_web")
}
DATABASES['default']['ATOMIC_REQUESTS'] = True
DATABASES['default']['ENGINE'] = 'django.contrib.gis.db.backends.postgis'
GEOPOSITION_GOOGLE_MAPS_API_KEY = '<API_KEY>'
GEOPOSITION_MAP_OPTIONS = {
'minZoom': 3,
'maxZoom': 15,
}
GEOPOSITION_MARKER_OPTIONS = {
'cursor': 'move'
}
INSTALLED_APPS = [
...
'geoposition',
]
from django.contrib.gis.db import models
from geoposition.fields import GeopositionField
class House(models.Model):
...
location = GeopositionField()
问题:
django.db.utils.ProgrammingError: data type character varying has no default operator class for access method "gist"
HINT: You must specify an operator class for the index or define a default operator class for the data type.
参考文献:
Django django-location-field missing API Keys
https://github.com/caioariede/django-location-field
答案 0 :(得分:1)
如果您使用的是postgres,您可能需要安装gist模块,如文档中所述:
https://www.postgresql.org/docs/9.2/static/btree-gist.html
您可以使用btree_gist扩展名来定义排除约束 在普通标量数据类型上,然后可以与范围组合 排除最大灵活性。例如,在btree_gist之后 安装后,以下约束将拒绝重叠范围 只有会议室号码相同: