Do not import aldryn_search outside PostIndex in search_indexes.py
See original GitHub issueDescription
We’re not using aldryn_search
at all, but we’re using django-haystack
in order to index elements of our websites. We had installed djangocms_blog
.
Haystack allows to exclude Indexes with its EXCLUDED_INDEXES paremeter, but it only excludes the content of the Index class.
The problem here is that you include aldryn_search
submodules outside the PostIndex, and so when I prevent your search_indexes.py
from being used by haystack using "EXCLUDED_INDEXES": ["djangocms_blog.search_indexes.PostIndex"],
, it always try to import aldryn_search
, even without using your PostIndex
at all.
Steps to reproduce
- Do not install
aldryn_search
. - Try to index something on the project using
django-haystack
, but not djangocms_blog (thanks to"EXCLUDED_INDEXES": ["djangocms_blog.search_indexes.PostIndex"],
). - Exception:
File "[...]djangocms_blog/search_indexes.py", line 4, in <module> from aldryn_search.helpers import get_plugin_index_data ModuleNotFoundError: No module named 'aldryn_search'
Expected solution
Move lines aldryn_search
imports in search_indexes.py
inside the class:
https://github.com/nephila/djangocms-blog/blob/99ab6a1be8a930972d9712321a17ac67a2354bab/djangocms_blog/search_indexes.py#L11
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top GitHub Comments
@corentinbettiol definitely nothing wrong! Thanks for reviewing it, I amended the documentation as suggested
@yakky Done. I think it’s my first review, I don’t really know if I did anything wrong.