python - Flask-Whooshee 错误 'WhoosheeQuery' 对象没有属性 '_join_entities'
问题描述
这是我基于模型的 flask-sqlalchemy
@whooshee.register_model('title','content')
class PostModel(db.Model):
__tablename__ = 'post'
id = db.Column(db.Integer,primary_key=True,autoincrement=True)
title = db.Column(db.String(200),nullable=False)
content = db.Column(db.Text,nullable=False)
create_time = db.Column(db.DateTime,default=datetime.now)
read_count = db.Column(db.Integer,default=0)
board_id = db.Column(db.Integer,db.ForeignKey("board.id"))
author_id = db.Column(db.String(100),db.ForeignKey("front_user.id"),nullable=False)
@bp.route('/search/')
def index_search():
q = request.args.get('q','')
print(q)
if q == '':
flash('enter key words','warning')
return redirect(url_for('front.index'))
result = PostModel.query.whooshee_search(q).order_by(PostModel.create_time.desc()).all()
print(result)
return render_template('front/front_search.html',result=result)
如果 self._join_entities 和 isinstance(self._join_entities[0], Mapper): AttributeError: 'WhoosheeQuery' 对象没有属性 '_join_entities'
你能告诉我如何解决这个问题吗?</p>
解决方案
在 flask_whooshee.py 模块中注释掉这部分。这个对我有用。
if self._join_entities and isinstance(self._join_entities[0], Mapper):
# SQLAlchemy >= 0.8.0
entities.update(set([x.entity for x in self._join_entities]))
else: # SQLAlchemy < 0.8.0 实体.更新(设置(self._join_entities))
推荐阅读
- java - 如何从 835 EDI 文件中提取数据?
- java - 插件 org.springframework.boot:spring-boot-maven-plugin?
- android - 无法在 android studio 上从 github 导入项目
- python - Python结合两个ndarrays
- asp.net-mvc - 为什么我的 MVC Web 应用程序时区在 Azure 中设置不正确?
- actions-on-google - Actions SDK:使用“speak to”或“ask”调用操作
- javascript - Firebase / Firestore:不存在文档,但应该
- javascript - 执行与此 SQL 查询相同的操作,但使用 javascript
- php - 媒体库未显示 + Wordpress 中的某些插件的图标
- java - 在画布上绘制只需启动 Activity