2016-08-14 58 views
2

我正在使用由Django 1.10提供的Postgres进行全文搜索并且得到一个NotImplementedError错误。我使用的搜索查询是:在Django中使用Postgres搜索时出现NotImplementedError错误1.10

Application.objects.filter(applicant_data__search='test') 

的错误是:

NotImplementedError: Add 'django.contrib.postgres' to settings.INSTALLED_APPS to use the search operator. 

我INSTALLED_APPS设置包括django.contrib.postgres:

INSTALLED_APPS = [ 
'django.contrib.admin', 
'django.contrib.auth', 
'django.contrib.contenttypes', 
'django.contrib.sessions', 
'django.contrib.messages', 
'django.contrib.staticfiles', 
'django.contrib.postgres', 
'main', 
] 

我使用的psycopg2的我的db引擎:

DATABASES = { 
'default': { 
    'ENGINE': 'django.db.backends.postgresql_psycopg2', 
    'NAME': 'dbname', 
    'USER': 'username', 
    'PASSWORD': '', 
    'HOST': 'localhost', 
} 
} 

我的模式是:

class Application(models.Model): 
    applicant_data = JSONField() 

当我从Django的shell中运行get_app_config,Postgres的应用程序返回正确的值:

from django.apps import apps 
apps.get_app_config('postgres').name 
'django.contrib.postgres' 

功能扔NotImplementedError是django.db.backends的fulltext_search_sql。 postgres,所以我的猜测是,django.contrib.postgres要么没有被正确加载,要么被默认的django postgres后端所取代。

不知道该从哪里出发,任何人都有类似的问题和/或见解?

回答

4

找出此错误的原因 - 全文搜索运算符不适用于JSON字段。

+0

这仍然是一个问题? – najeeb

相关问题