title: Beating circular references in flask blueprints
body: <p>Here the problem is that I am trying to use my db connection in my blueprints, but I cannot seem to avoid an importation error despite my efforts to import. Here is my original question:</p>
  
  <p><a href="https://stackoverflow.com/questions/33166612/blueprints-pymongo-in-flask">Blueprints, PyMongo in Flask</a></p>
  
  <p>There is a suggestion from the original poster at: <a href="https://stackoverflow.com/questions/22929839/circular-import-of-db-reference-using-flask-sqlalchemy-and-blueprints">Circular import of db reference using Flask-SQLAlchemy and Blueprints</a>, but there has to be an easier way of doing things.</p>
  
  <p>I've tried the suggestion in my original question which leads to the importation error when trying to pull in the mongo connection in my blueprint. The error is:</p>
  
  <pre><code>ImportError: cannot import name 'mongo'
  </code></pre>
  
  <p>I've also tried moving the import location so its after the db connection in my login.py, however none of this seems to work. Where can I find a simple working example that I can use that appears to be bulletproof.</p>