title: Failed to find Flask application or factory in module "config" Use "FLASK_APP=config:name to specify one
body: <p>I am doing the flask training course <a href="https://habr.com/en/post/346344/" rel="nofollow noreferrer">enter link description here</a></p>
  
  <p>I'm install Flask-SQLAlchemy in a virtual environment.
  I'm install Flask-Migrate:
      pip install flask-migrate</p>
  
  <p>Created a class config.py:</p>
  
  <pre><code>import os
  basedir = os.path.abspath(os.path.dirname(__file__))
  
  class Config(object):
      SECRET_KEY = os.environ.get('SECRET_KEY') or '*********'    
      SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or 'sqlite:///' + os.path.join(basedir, 'app.db')  
      SQLALCHEMY_TRACK_MODIFICATIONS = False
  </code></pre>
  
  <p>In models.py I have two models:</p>
  
  <pre><code>from datetime import datetime
  from app import db
  
  class User(db.Model):
      id = db.Column(db.Integer, primary_key=True)
      username = db.Column(db.String(64), index=True, unique=True)
      email = db.Column(db.String(120), index=True, unique=True)
      password_hash = db.Column(db.String(128))
      posts = db.relationship('Post', backref='author', lazy='dynamic')
  
      def __repr__(self):
          return '&lt;User {}&gt;'.format(self.username)
  
  class Post(db.Model):
      id = db.Column(db.Integer, primary_key=True)
      body = db.Column(db.String(140))
      timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow)
      user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
  
      def __repr__(self):
          return '&lt;Post {}&gt;'.format(self.body)
  </code></pre>
  
  <p>In testapp.py only:</p>
  
  <pre><code>from app import app
  </code></pre>
  
  <p>In file <strong>init</strong>.py </p>
  
  <pre><code>from flask import Flask
  from flask_sqlalchemy import SQLAlchemy
  from flask_migrate import Migrate
  from config import Config
  
  app = Flask(__name__)
  app.config.from_object(Config)
  db = SQLAlchemy(app)
  migrate = Migrate(app, db)
  
  from app import routes, models
  </code></pre>
  
  <p>Structure my app:</p>
  
  <pre><code>testapp\
    venv\
    app\
      templates\
          base.html
          index.html
          login.html 
      __init__.py
      routes.py
      forms.py
      models.py    
    testapp.py
    config.py
  </code></pre>
  
  <p>In a Python interpreter session, do the following
  from app.models import User
  and get an error:</p>
  
  <pre><code>(venv) C:\Users\User\testapp&gt;python
  Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 
  64 bit
  (AMD64)] on win32
  Type "help", "copyright", "credits" or "license" for more information.
   &gt;&gt;&gt; from app.models import User
  Traceback (most recent call last):
     File "&lt;stdin&gt;", line 1, in &lt;module&gt;
     File "C:\Users\User\testapp\app\__init__.py", line 4, in &lt;module&gt;
       from config import Config
     File "C:\Users\User\testapp\config.py", line 8
       SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
                                                                   ^
  TabError: inconsistent use of tabs and spaces in indentation
   &gt;&gt;&gt;
  </code></pre>
  
  <p>Set the environment variable for the new config module
      set FLASK_APP=config.py</p>
  
  <p>When I execute the command:</p>
  
  <pre><code>flask db init
  </code></pre>
  
  <p>Complete error log:</p>
  
  <pre><code>(venv) C:\Users\User\testapp&gt;flask db init
  Usage: flask db init [OPTIONS]
  
  Error: Failed to find Flask application or factory in module "config". Use "FLAS
  K_APP=config:name to specify one.
  
  (venv) C:\Users\User\testapp&gt;
  </code></pre>
  
  <p>What am I doing wrong? Help</p>