When running locally my Flask app, I can use a common import:
from models import MyModel
But when running on Heroku, I need to change it to:
from .models import MyModel
Why does that happen?
When running locally my Flask app, I can use a common import:
from models import MyModel
But when running on Heroku, I need to change it to:
from .models import MyModel
Why does that happen?
I'm not sure why on Heroku this happens. But it has to do with the Python path.
If you specify the path where the app is on the Procfile, it will work.
Before:
web: gunicorn src.api:api
After:
web: gunicorn src.api:api --pythonpath=./src
Considering that the main file is named api.py and is located inside a folder called src.