whoosh mysql_使用WhooshAlchemy报错'function' object has no attribute 'config'

我想用WhooshAlchemy做全文搜索,但是用的时候报错:

4f06cde3e71b6bea6631a619ace951b6.png

我的config.py:

import os

from app import basedir

CSRF_ENABLED = True

SECRET_KEY = 'hard to guess string'

SQLALCHEMY_TRACK_MODIFICATIONS = False

basedir = os.path.abspath(os.path.dirname(__file__))

WHOOSH_BASE = os.path.join(basedir, 'search.db')

__init__.py:

def create_app():

app = Flask(__name__)

app.config.from_pyfile('config')

app.config['SQLALCHEMY_DATABASE_URI'] = \

'sqlite:///' + path.join(basedir, 'data.sqlite')

# 'mysql://root:123456@localhost/shop'

app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True

app.config.from_object('config')

db.init_app(app)

bootstrap.init_app(app)

login_manager.init_app(app)

from auth import auth as auth_blueprint

from main import main as main_blueprint

models.py:

class Post(db.Model):

__tablename__ = 'posts'

__searchable__ = ['title']

id = db.Column(db.Integer, primary_key=True)

title = db.Column(db.String)

body = db.Column(db.String)

created = db.Column(db.DateTime, index=True, default=datetime.utcnow)

clicks = db.Column(db.Integer)

comments = db.relationship('Comment', backref='post', lazy='dynamic')

author_id = db.Column(db.Integer, db.ForeignKey('users.id'))

if enable_search:

whooshalchemy.whoosh_index(app, Post)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值