3

I'm using the full text search for Postgres offered by Django 1.10 and getting a NotImplementedError. The search query I'm using is:

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

The error is:

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

My INSTALLED_APPS setting includes 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',
] 

I'm using psycopg2 for my db engine:

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

My model is:

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

When I run get_app_config from the django shell, the postgres app returns correct values:

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

The function throwing the NotImplementedError is the fulltext_search_sql from django.db.backends.postgres, so my guess is that django.contrib.postgres is either not being loaded correctly or is being replaced by the default django postgres backend.

Not sure where to go from here, anyone have a similar issue and/or insights?

1 Answer 1

5

Figured out the cause of this error - the full text search operator does not work for JSON fields.

Sign up to request clarification or add additional context in comments.

1 Comment

Is this still an issue ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.