title: Importing from __init__ in Flask
body: <p>I am wanting to import a class from my <code>__init__</code> file. But I am unsuccessful in importing it. This is my directory structure</p>
  
  <pre><code>/fitBody_app
    /fitBody
      /static
      /templates
      __init__.py
      models.py
      views.py
  
  run.py
  </code></pre>
  
  <p>These are all the imports of my <code>__init__.py</code> file:</p>
  
  <pre><code>import os
  
  from flask import Flask
  from flask_admin import Admin
  from flask_admin.contrib.sqla import ModelView
  from flask_sqlalchemy import SQLAlchemy
  from wtforms import fields, widgets
  
  from fitBody.views import my_app
  from flask_bootstrap import Bootstrap
  
  app = Flask(__name__)
  db = SQLAlchemy(app)
  </code></pre>
  
  <p>These are all my imports in my <code>views.py</code> file:</p>
  
  <pre><code>import bcrypt
  from flask import flash, redirect, render_template, request, session, Blueprint, url_for
  from fitBody.models import RegistrationForm
  from fitBody.models import cursor, conn
  from fitBody import db
  
  my_app = Blueprint('fitBody', __name__)
  
  &lt;......&gt;
  </code></pre>
  
  <p>When I try to run the file, this is my traceback:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/Users/kai/github-projects/fitBody_app/run.py", line 1, in &lt;module&gt;
      from fitBody import app
    File "/Users/kai/github-projects/fitBody_app/fitBody/__init__.py", line 9, in &lt;module&gt;
      from fitBody.views import fitBody
    File "/Users/kai/github-projects/fitBody_app/fitBody/views.py", line 8, in &lt;module&gt;
      from fitBody import db
  ImportError: cannot import name 'db'
  </code></pre>
  
  <p>I had thought that since I am importing from within the same folder that it is possible to just give the import like this.</p>
  
  <p>How would I go about importing the <code>db</code> object from the <code>__init__.py</code> file?</p>