【问题标题】:django-machina search returns no resultdjango-machina 搜索没有返回结果
【发布时间】:2021-08-23 15:14:40
【问题描述】:

我已按照Tutorial 中给出的所有步骤进行操作,但我的项目的搜索功能无法正常工作。而 django-machina 给出的示例项目在搜索中运行良好。所以有人可以告诉我缺少的东西是什么。我还重建并更新了索引。但我的搜索仍然没有给出任何结果。它总是 0 结果没有错误。

当我运行重建索引命令时,我收到以下错误

python3 manage.py rebuild_index

/usr/local/lib/python3.8/site-packages/jose/backends/cryptography_backend.py:18: CryptographyDeprecationWarning: int_from_bytes is deprecated, use int.from_bytes instead
  from cryptography.utils import int_from_bytes, int_to_bytes
WARNING: This will irreparably remove EVERYTHING from your search index in connection 'default'.
Your choices after this are to restore from backups or rebuild via the `rebuild_index` command.
Are you sure you wish to continue? [y/N] y
Removing all documents from your index because you said so.
/usr/local/lib/python3.8/site-packages/haystack/backends/simple_backend.py:31 UserWarning: clear is not implemented in this backend
All documents removed.
Indexing 13 Posts
/usr/local/lib/python3.8/site-packages/haystack/backends/simple_backend.py:25 UserWarning: update is not implemented in this backend

【问题讨论】:

  • 您能提供您的代码吗?没有看到你的实现,很难指出哪里出了问题。

标签: python-3.x django django-haystack


【解决方案1】:

您可以找到解决方案here。添加设置后请做python3 manage.py update_index 或者你可以通过代码来完成

from django.core import management
management.call_command('update_index')

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-12
    • 2018-01-08
    • 2016-04-30
    • 1970-01-01
    • 2021-09-29
    相关资源
    最近更新 更多