gpt4 book ai didi

django.db.utils.ProgrammingError : data type character varying has no default operator class for access method "gin"

转载 作者:行者123 更新时间:2023-12-04 01:56:58 26 4
gpt4 key购买 nike

我正在做一个 django 项目,我想在我的模型属性上创建 gin 索引。
我想创建 Gin 索引

 SchoolName = models.CharField(max_length=200, blank=False, null=False)

但是,我收到此错误
 django.db.utils.ProgrammingError: data type character varying has no default operator class for access method "gin"

帮我找出这个错误

最佳答案

创建迁移文件以安装 BtreeGinExtension启用 GIN 索引建立在 varchar 上数据类型。

from django.contrib.postgres.operations import BtreeGinExtension

class Migration(migrations.Migration):
...

operations = [
BtreeGinExtension(),
...
]

引用:
  • https://www.postgresql.org/docs/current/static/gin-builtin-opclasses.html
  • https://docs.djangoproject.com/en/2.0/ref/contrib/postgres/indexes/#ginindex
  • https://docs.djangoproject.com/en/2.0/ref/contrib/postgres/operations/
  • 关于django.db.utils.ProgrammingError : data type character varying has no default operator class for access method "gin",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49922092/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com