I have a problem setting up whoosh_search
in my application.
Very fast, let me show you my files configurations.
settings.py:
basedir = os.path.abspath(os.path.dirname(__file__))
WHOOSH_BASE = os.path.join(basedir, 'search.db')
models.py:
import flask_whooshalchemy as whooshalchemy
class Post(Base):
__tablename__ = 'post'
__searchable__ = ['title', 'type_course']
id = db.Column(db.Integer, primary_key=True)
author_id = db.Column(db.Integer, db.ForeignKey('author.id'))
title = db.Column(db.String(500))
type_course = db.Column(db.String(20))
about_course = db.Column(db.Text())
Inside the shell if i tried to test if it does work or not am getting this error:
>>> from pro.main.models import Post
>>> p = Post.query.whoosh_search('cool')
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'BaseQuery' object has no attribute 'whoosh_search'
I have read another articles that issued this problem but am still getting the same issue.
Another thing to mention, i have this code almost in all files:
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
, maybe this cause some problems !!, am not really sure because the application worked without any errors .
Eventually, any help would be tons appreciated .