【问题标题】:Can not migrate schema django-geoposition无法迁移架构 django-geoposition
【发布时间】:2017-09-18 09:04:33
【问题描述】:

我可以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

【问题讨论】:

    标签: python django django-geoposition


    【解决方案1】:

    如果您使用的是 postgres,您可能需要按照文档中的说明安装 gist 模块:

    https://www.postgresql.org/docs/9.2/static/btree-gist.html

    您可以使用 btree_gist 扩展来定义排除约束 在普通标量数据类型上,然后可以与范围组合 最大的灵活性排除。例如,在 btree_gist 是 安装后,以下约束将拒绝重叠范围 仅当会议室编号相等时:

    【讨论】:

    • 所以让我在 4 分钟后接受。请稍等。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 2020-12-05
    • 2021-09-08
    • 2013-10-06
    • 2017-08-29
    • 2018-11-01
    • 2021-10-25
    • 1970-01-01
    • 2021-06-27
    相关资源
    最近更新 更多