Skip to content
Advertisement

What triggers the KeyError: ‘SQLALCHEMY_TRACK_MODIFICATIONS’?

I already looked at other threads concerning this error, which all indicate that this error is due to multiple instances of “app = Flask(name)”. But since I only have one, I hope someone here can help me figure this one out.

I try to keep the code minimal, but enough to reproduce the error

routes.py:

JavaScript

models.py:

JavaScript

create statements for the Postgres Database:

JavaScript

EDIT: THIS IS THE ERROR LOG:

JavaScript

Advertisement

Answer

You need to restructure your code.

remove the flask_sqlalchemy import from models.py and add it in routes.py

bring this line just before app.route(/register)….

JavaScript

remove db = SQLAlchemy() this from models.py and add this import statement

JavaScript

and finally include this line

JavaScript

below app.secret_key = "secret"

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement