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後端所取代。
不知道該從哪裏出發,任何人都有類似的問題和/或見解?
這仍然是一個問題? – najeeb