1

i have have the following folder structure for a simple flask-app.

Folder structure

with a one-page structure i was able to import models in python console, but since i changed the structure to a scalable model, i cant seem to find a way to import models into my python console, i get this error.

RuntimeError: application not registered on db instance and no application bound to current context

is there a workaround for this ?

Hara
  • 71
  • 1
  • 8
  • Did you try from `app.catalog.models import ModelName` ? –  Jun 16 '17 at 15:56
  • yes kiran, they get imported without any issues, but when i create an instance of a table (class), it throws the above said error... – Hara Jun 16 '17 at 16:00
  • Can you share your code that you are trying? –  Jun 16 '17 at 16:01

1 Answers1

1

You need to be running in an application context. Use the flask shell command to set this up for you.

FLASK_APP=app flask shell

Or set it up manually:

>>> from app import app
>>> app.app_context().push()
davidism
  • 121,510
  • 29
  • 395
  • 339