我们需要使用带有unaccent扩展名的Django搜索。到目前为止,我通过迁移安装了扩展程序,并将“ django.contrib.postgres”添加到已安装的应用程序中。在我写了一些代码来查询数据之后。我不知道为什么,但是我不断收到此错误,我找不到任何有关其含义的信息。
text search configuration "unaccent" does not exist at character 701
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('team', '0006_team_team_image'),
]
operations = [
UnaccentExtension()
]
from django.contrib.postgres.search import SearchVector, SearchQuery
sv = SearchVector('first_name', 'last_name', 'email')
parsed_body = json.loads(request.body.decode('utf-8'))
query = parsed_body['query']
users = User.objects.annotate(search = sv).filter(search = SearchQuery(query, config = 'unaccent'))
response = {
'users': [{'full_name': u.get_full_name(), 'email': u.email, 'pk': u.pk} for u in users]
}