Задать вопрос
  • Did you forget to call 'init_app', or did you create multiple 'SQLAlchemy' instances?

    @AloneWasser Автор вопроса
    Ivan Kudinov, ладно, проблема образовывается, когда я перемещаю бд модели в другой файл, я просто перекину обратно в апп бдшку и все работает, но интересно конечно было бы покопаться с этим, но я правда не понимаю в чем проблема, тк питон только изучаю
  • Did you forget to call 'init_app', or did you create multiple 'SQLAlchemy' instances?

    @AloneWasser Автор вопроса
    Ivan Kudinov, сервер запускается, как только захожу на любую из страниц, выдается ошибка
  • Did you forget to call 'init_app', or did you create multiple 'SQLAlchemy' instances?

    @AloneWasser Автор вопроса
    Ivan Kudinov, * Serving Flask app 'app'
    * Debug mode: on
    WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
    * Running on 127.0.0.1:5000
    Press CTRL+C to quit
    * Restarting with stat
    * Debugger is active!
    * Debugger PIN: 825-218-218
    127.0.0.1 - - [24/May/2023 22:11:31] "GET / HTTP/1.1" 500 -
    Traceback (most recent call last):
    File "C:\Users\AloneWasser\AppData\Local\Programs\Python\Python310\lib\site-packages\flask\app.py", line 2213, in __call__
    return self.wsgi_app(environ, start_response)
    File "C:\Users\AloneWasser\AppData\Local\Programs\Python\Python310\lib\site-packages\flask\app.py", line 2193, in wsgi_app
    response = self.handle_exception(e)
    File "C:\Users\AloneWasser\AppData\Local\Programs\Python\Python310\lib\site-packages\flask\app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
    File "C:\Users\AloneWasser\AppData\Local\Programs\Python\Python310\lib\site-packages\flask\app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
    File "C:\Users\AloneWasser\AppData\Local\Programs\Python\Python310\lib\site-packages\flask\app.py", line 1482, in full_dispatch_request
    rv = self.preprocess_request()
    File "C:\Users\AloneWasser\AppData\Local\Programs\Python\Python310\lib\site-packages\flask\app.py", line 1974, in preprocess_request
    rv = self.ensure_sync(before_func)()
    File "C:\Users\AloneWasser\Desktop\21\project\app.py", line 77, in setup
    create_default_admin()
    File "C:\Users\AloneWasser\Desktop\21\project\app.py", line 43, in create_default_admin
    admin = User.query.filter_by(username=default_admin_username, is_admin=True).first()
    File "C:\Users\AloneWasser\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlalchemy\orm\query.py", line 2752, in first
    return self.limit(1)._iter().first() # type: ignore
    File "C:\Users\AloneWasser\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlalchemy\orm\query.py", line 2855, in _iter
    result: Union[ScalarResult[_T], Result[_T]] = self.session.execute(
    File "C:\Users\AloneWasser\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlalchemy\orm\session.py", line 2229, in execute
    return self._execute_internal(
    File "C:\Users\AloneWasser\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlalchemy\orm\session.py", line 2112, in _execute_internal
    bind = self.get_bind(**bind_arguments)
    File "C:\Users\AloneWasser\AppData\Local\Programs\Python\Python310\lib\site-packages\flask_sqlalchemy\session.py", line 53, in get_bind
    engines = self._db.engines
    File "C:\Users\AloneWasser\AppData\Local\Programs\Python\Python310\lib\site-packages\flask_sqlalchemy\extension.py", line 639, in engines
    raise RuntimeError(
    RuntimeError: The current Flask app is not registered with this 'SQLAlchemy' instance. Did you forget to call 'init_app', or did you create multiple 'SQLAlchemy' instances?
  • Did you forget to call 'init_app', or did you create multiple 'SQLAlchemy' instances?

    @AloneWasser Автор вопроса
    RuntimeError: The current Flask app is not registered with this 'SQLAlchemy' instance. Did you forget to call 'init_app', or did you create multiple 'SQLAlchemy' instances?