Attributeerror: 'sqlalchemy' Object Has No Attribute 'models'
AttributeError: sqlalchemy object has no attribute 'Models' and some times ModuleNotFoundError: No module named 'models' error is occurring. I already installed all requirements li
Solution 1:
Make shure in your models.py in your db object is
db = SQLAlchemy()
NOT db = SQLAlchemy , because SQLAlchemy is a class
Solution 2:
If it doesn't work try the following.
db.init_app(app)
For example
#main.pyfrom flask import Flask
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///database.db'# Database URL
db = SQLAlchemy(app)
db.init_app(app)
Post a Comment for "Attributeerror: 'sqlalchemy' Object Has No Attribute 'models'"