title: Getting an error: AttributeError: 'Flask' object has no attribute 'login_manager'
body: <p>I am trying to run my flask app, but every time I load my index page, it gives me the error:</p>
  <pre><code>AttributeError: 'Flask' object has no attribute 'login_manager'. 
  </code></pre>
  <p>It works before I put in this specific code</p>
  <pre><code>bp = flask.Blueprint(&quot;bp&quot;, __name__, template_folder=&quot;./build&quot;)
  
  @bp.route('/index')
  @login_required
  def index():
      # TODO: insert the data fetched by your app main page here as a JSON
      DATA = {&quot;your&quot;: &quot;data here&quot;}
      data = json.dumps(DATA)
      return flask.render_template(
          &quot;index.html&quot;,
          data=data,
      )
  
  app.register_blueprint(bp)
  </code></pre>
  <p>This is my current code where it does work</p>
  <pre><code>@app.route(&quot;/index&quot;, methods=[&quot;GET&quot;, &quot;POST&quot;])
  def index():
      global current_user
      if not current_user:
          return flask.redirect(flask.url_for(&quot;login&quot;))
      if flask.request.method == &quot;GET&quot;:
          track_name, genius_link, track_artist, track_image, track_url = render()
          # If user has no favorite artists, redirect back to profile.
          if track_name == None:
              return flask.redirect(flask.url_for(&quot;profile&quot;))
          return flask.render_template(
              &quot;index.html&quot;,
              variable=track_name,
              variable1=genius_link,
              variable2=track_artist,
              variable3=track_image,
              variable4=track_url,
          )
      else:
          valid_artist = validate_and_insert_artist(flask.request.form[&quot;artistId&quot;])
          if not valid_artist:
              return flask.render_template(&quot;index.html&quot;, error=True)
          else:
              track_name, genius_link, track_artist, track_image, track_url = render()
              # If user has no favorite artists, redirect back to profile.
              if track_name == None:
                  return flask.redirect(flask.url_for(&quot;profile&quot;))
              return flask.render_template(
                  &quot;index.html&quot;,
                  variable=track_name,
                  variable1=genius_link,
                  variable2=track_artist,
                  variable3=track_image,
                  variable4=track_url,
              )
  </code></pre>
  <p>I am not sure why as soon as I put in the blueprint code, it stops working and gives me that error</p>
  <p>This is my login.html</p>
  <pre><code>@app.route(&quot;/login&quot;, methods=[&quot;GET&quot;, &quot;POST&quot;])
  def login():
      global current_user
      if current_user:
          return flask.redirect(flask.url_for(&quot;profile&quot;))
      if flask.request.method == &quot;GET&quot;:
          return flask.render_template(&quot;login.html&quot;)
      if flask.request.method == &quot;POST&quot;:
          username = flask.request.form[&quot;username&quot;]
          cursor.execute(
              &quot;SELECT user_name FROM public.users WHERE user_name = %s&quot;, [username]
          )
          results = cursor.fetchall()
          if len(results) != 0:  # if a user exists, &quot;log&quot; them in
              current_user = username
              return flask.redirect(flask.url_for(&quot;profile&quot;))
          else:
              return flask.render_template(&quot;login.html&quot;, error=True)
  </code></pre>