My problem is: I am unable to import the model's Role
class (Or anything from the models for that matter).
I have a simple file structure in my Flask app (theres more but the problem is here):
myapp
|--serve.py
|--models.py
|--front.py
In models.py:
...
db = SQLAlchemy(app)
class Role(db.Model, RoleMixin):
id = db.Column(db.Integer(), primary_key=True)
name = db.Column(db.String(80), unique=True)
description = db.Column(db.String(255))
...
In my serve.py:
...
app = Flask(__name__)
...
In my front.py:
class SetupUserForm(Form):
from models import Role
roles = RadioField(choices=[(r.name,r.name.title()) for r in Role.query.all()],validators=[validators.Required()])
I am getting this error:
ImportError: cannot import name Role
This is the gist.
I can import the app
from the model.
I have tried adding in an __init__.py
file in the myapp (the main) directory.
I do not understand imports 100%.