Django is a very attractive tool to rapidly create (relatively) small in-house web-applications with default autogenerated Django Admin user interface. Sooner or later one feels that default Django Admin search capabilities are somewhat limited and something like full-text search could be more desirable. Installing Haystack with Whoosh backend seems to be an optimal solution for such small applications. Unfortunately, Haystack with Whoosh integration module spoils Django Admin user interface and makes search results list virtually useless. Namely, after one performs full-text search
- Django Admin left navigation panel disappears. - Column sorting no longer works in Django Admin table view. - Row selection column disappears from Django Admin table view. - Action selection menu becomes unavailable. - Whoosh wildcard search does not work.
The fix
Let's assume that one has installed Django, Haystack and Whoosh in a virtual environment in ~/code/django.venv directory.
Module ~/code/django.venv/lib/python3.10/site-packages/haystack/admin.py has to be replaced with admin.py file from this project. Edit module ~/code/django.venv/ lib/ python3.10 /site-packages/ haystack/ backends/ whoosh_backend.py. Look for WhooshSearchBackend class definition circa lines 99, 100 and comment out lines with "*" and "?"
Ratings & Comments
0 Comments