ile uygulama çalıştırırken kaydedilmiyor Geliştirme aşamasında çalışan bir uygulama var, ancak Gunicorn ile çalıştırmaya çalıştığımda "sqlalchemy uzantısı kayıtlı değil" hatası veriyor. Okuduğumdan, bir yerlerde app.app_context()
'u aramam gerektiği gibi görünüyor, ama emin değilim. Bu hatayı nasıl düzeltirim?SQLAlchemy eklentisi, Gunicorn
# run in development, works
python server.py
# try to run with gunicorn, fails
gunicorn --bind localhost:8000 server:app
AssertionError: The sqlalchemy extension was not registered to the current application. Please make sure to call init_app() first.
server.py
:
from flask.ext.security import Security
from database import db
from application import app
from models import Studio, user_datastore
security = Security(app, user_datastore)
if __name__ == '__main__':
# with app.app_context(): ??
db.init_app(app)
app.run()
application.py
:
from flask import Flask
app = Flask(__name__)
app.config.from_object('config.ProductionConfig')
database.py
:
from flask.ext.sqlalchemy import SQLAlchemy
db = SQLAlchemy()
Kolaydı, teşekkürler! – duffn