Works locally but not in render

I have tried to deploy my website on render and worked through dependency issues for a good bit even though in my venv everything worked. I now have the website deployed and it says its live but it gives me an error and when I go to the link I get an error code 500 which is odd because the code on my side still works when I start up a server locally. This is my first time deploying a website and I’m pretty lost at what to do.

This is the error in the logs ==> Your service is live :tada:
[2024-06-03 19:55:07 +0000] [87] [ERROR] Error handling request /
Traceback (most recent call last):
File “/opt/render/project/src/.venv/lib/python3.11/site-packages/gunicorn/workers/sync.py”, line 135, in handle
self.handle_request(listener, req, client, addr)
File “/opt/render/project/src/.venv/lib/python3.11/site-packages/gunicorn/workers/sync.py”, line 178, in handle_request
respiter = self.wsgi(environ, resp.start_response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/opt/render/project/src/models.py”, line 42, in connect_db
db.init_app(app)
File “/opt/render/project/src/.venv/lib/python3.11/site-packages/flask_sqlalchemy/extension.py”, line 311, in init_app
if “sqlalchemy” in app.extensions:
^^^^^^^^^^^^^^
AttributeError: ‘dict’ object has no attribute ‘extensions’
127.0.0.1 - - [03/Jun/2024:19:55:07 +0000] “GET / HTTP/1.1” 500 0 “-” “-”

Hi,

This looks like a code issue and not a Render one.

The issue appears to be these lines you shared:

File “/opt/render/project/src/.venv/lib/python3.11/site-packages/flask_sqlalchemy/extension.py”, line 311, in init_app
if “sqlalchemy” in app.extensions:
^^^^^^^^^^^^^^
AttributeError: ‘dict’ object has no attribute ‘extensions’

Something in relation to the flask_sqlalchemy package, trying to access an non-existent extensions attribute on app. You’ll need to try and debug that.