title: Flask-Login | url query string arg 'next'
body: <p>Auth blueprint login route:</p>
  <pre><code>@auth.route('/login', methods=['GET', 'POST'])
  def login():
  if request.method == 'POST':
      doctor_id = request.form.get('doctor-id')
      password = request.form.get('password')
      docktor = session.query(Doctor).filter_by(doctor_health_id=int(doctor_id)).first()
  
      if docktor:
          if docktor.verify_password(password):
              login_user(user=docktor)
              flash(&quot;Login Successful&quot;, &quot;ok&quot;)
              login_user(docktor)
  
              _next = request.args.get('next')
  
              print(_next)
              if _next is None or not _next.startswith('/'):
                  _next = url_for(&quot;medic.home&quot;)
                  print(_next)
                  return redirect(url_for('medic.home'))
  
          else:
              flash('wrong password')
              return redirect(url_for('auth.login'))
      else:
          flash('Wrong credentials')
          return url_for('auth.login')
  
  else:
      return render_template('auth/login.html')
  </code></pre>
  <p>Medic Blueprint home route:</p>
  <pre><code>@medic.route('/')
  @login_required
  def home():
      return render_template('medic/home.html')
  </code></pre>
  <p>So my problem is that i try to log in user using Flask-Login.... but I can't solve problem that my login route send me to</p>
  <pre><code>http://127.0.0.1:5000/auth/login?next=%2Fmedic%2F
  </code></pre>
  <p>this url...</p>
  <p>I can not figure what am I doing wrong here...</p>
  <p>I read docs from Flask and Flask-Login and search on stackoverflow but solutions that i fund did not work for me..
  How do I solve that query string problem?</p>
  <p>request log is:</p>
  <pre><code>127.0.0.1 - - [13/Feb/2021 11:18:37] &quot;POST /auth/login HTTP/1.1&quot; 302 -
  127.0.0.1 - - [13/Feb/2021 11:18:37] &quot;GET /medic/ HTTP/1.1&quot; 302 -
  127.0.0.1 - - [13/Feb/2021 11:18:37] &quot;GET /auth/login?next=%2Fmedic%2F             
  HTTP/1.1&quot; 200 -`
  </code></pre>