close

[Solved] ‘No application found. Either work inside a view function or push an application context.’

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error ‘No application found. Either work inside a view function or push an application context.’ in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How ‘No application found. Either work inside a view function or push an application context.’ Error Occurs?

Today I get the following error ‘No application found. Either work inside a view function or push an application context.’ in python.

How To Solve ‘No application found. Either work inside a view function or push an application context.’ Error ?

  1. How To Solve 'No application found. Either work inside a view function or push an application context.' Error ?

    To Solve 'No application found. Either work inside a view function or push an application context.' Error Use with app.app_context() to push an application context when creating the tables.

  2. 'No application found. Either work inside a view function or push an application context.'

    To Solve 'No application found. Either work inside a view function or push an application context.' Error Use with app.app_context() to push an application context when creating the tables.

Solution 1

Use with app.app_context() to push an application context when creating the tables.

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'My connection string'
db.init_app(app)

with app.app_context():
    db.create_all()

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read