简体   繁体   中英

Flask-SQLAlchemy. AttributeError: module '<…>.db' has no attribute 'Model'

so I have one module called 'co'.

Here is it's __init__.py

...
db = SQLAlchemy(app)
...

And models.py

...
from co import db
class BaseModel(db.Model):
    id = db.Column(db.Integer, primary_key=True)
...

Running flask db init is giving me

AttributeError: module 'co.db' has no attribute 'Model'

What am I doing wrong here?

This would imply you have the following folder structure

root
 - co
   - __init__.py
   - models.py
   - routes.py
 - myapp.py

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM