-
Notifications
You must be signed in to change notification settings - Fork 151
Is there a way to import all db.models for my shell? #147
Comments
|
FWIW, here's how I handle auto-imports of my models when I run
Works fine for me |
Jeff's example should end up in docs. |
@jeffwidman this would mean that if my models are in different folders, i would have to import them individually. I was hoping to import all models from a model folder and then each class within each module... more like a for loop |
I agree it's a pain. My wife was working on a somewhat similar problem recently around looping through |
Just if somebody ends up here and don't know how to import shell from flask_script import Shell
|
if someone would like to import all models from a package: import inspect
from app import db, models
def make_shell_context():
return dict(
db=db,
**dict(inspect.getmembers(models, inspect.isclass))) |
Is there a way to import all db.models for my shell when going interactive shell? I'm using sqlalchemy.
I'm using make_context and only able to pass models into the dictionary.... I want to be able to use the shell without having to do
every time I go into interactive shell
Thanks!
The text was updated successfully, but these errors were encountered: