diff --git a/DRFHTutorial/settings.py b/DRFHTutorial/settings.py index 1efdcf6..e55074a 100644 --- a/DRFHTutorial/settings.py +++ b/DRFHTutorial/settings.py @@ -9,7 +9,7 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.2/ref/settings/ """ - +import os from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. @@ -128,8 +128,8 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' HAYSTACK_CONNECTIONS = { - "default": { - # For Simple: - "ENGINE": "haystack.backends.simple_backend.SimpleEngine" + 'default': { + 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine', + 'PATH': os.path.join(os.path.dirname(os.path.dirname(__file__)), 'Whoosh'), }, } \ No newline at end of file diff --git a/README.md b/README.md index 898365e..48cc59d 100644 --- a/README.md +++ b/README.md @@ -18,4 +18,8 @@ ![](https://github.com/cs246810/DRFHTutorial/blob/master/api_test.png) 结果有点差强人意,确实出现了结果,但是,这里出现的说text为null的数据,显然我没有找到正确的使用drf_haystack -的方法。 \ No newline at end of file +的方法。 + +后来我换上whoosh之后,居然奇迹般的出现了结果。 + +![](https://github.com/cs246810/DRFHTutorial/blob/master/whoosh.png) \ No newline at end of file diff --git a/whoosh.png b/whoosh.png new file mode 100644 index 0000000..4325d6b Binary files /dev/null and b/whoosh.png differ