tbhaxor
tbhaxor

Reputation: 1943

Unable to import models from the local python file

I have installed flask and flask-sqlalchemy in my base environment of the conda. I defined the models in separate file (model.py), when I am trying to import it in my app.py file it's throwing the following error

enter image description here

Upvotes: 0

Views: 96

Answers (1)

Alveona
Alveona

Reputation: 978

When you write from model import User, you cause python to import from app import db, i.e. import app into app, which is not allowed in python

Please, take a look at this answer, I wrote it pretty straightforward how to solve this problem with flask-sqlalchemy:

https://stackoverflow.com/a/62991785/10468419

Upvotes: 1

Related Questions