Python Forum
Problem with arguments in route function.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with arguments in route function.
#1
I need to have two arguments in my search_results2 function but it keeps saying missing 1 required positional argument. I have no idea what to do with it i have two in there but it still saying one is missing. Could anyone help me with this?

Error:
TypeError: search_results2() missing 1 required positional argument: 'search2'
@app.route('/results2')
def search_results2(username, search2):
    
    results = []
    search_string = search2.data['search2']

    if search_string:
        if search2.data['select'] == 'Enummer':
            qry = db_session.query(Matrial, Enummer).filter(
                Enummer.id==Matrial.Enummer_id).filter(
                    Enummer.name.contains(search_string))
            results = [item[0] for item in qry.all()]
        elif search2.data['select'] == 'Varumärke':
            qry = db_session.query(Matrial).filter(
                Matrial.varumarke.contains(search_string))
            results = qry.all()
        elif search2.data['select'] == 'Produkt':
            qry = db_session.query(Matrial).filter(
                Matrial.produkt.contains(search_string))
            results = qry.all()
        else:
            qry = db_session.query(Matrial)
            results = qry.all()
    else:
        qry = db_session.query(Matrial)
        results = qry.all()

    if not results:
        flash('No results found!')
        return redirect(url_for("user_home", username=username))
    else:
        # display results
        table = Results2(results)
        table.border = True
        return render_template('results.html', table=tabl, username=username)
Reply


Messages In This Thread
Problem with arguments in route function. - by darktitan - Aug-25-2019, 09:02 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  how to create dynamic arguments to be passed in jinja template in url_for function? experimental 1 2,735 May-01-2020, 05:50 PM
Last Post: Larz60+
  How to POST html data to be handled by a route endpoint nikos 1 2,347 Mar-07-2020, 03:14 PM
Last Post: nikos
  Problem enabling http auth in a route nikos 2 2,738 Mar-02-2019, 01:13 PM
Last Post: nikos
  Passing a query value from a Bottle html template to a route with an encoding nikos 0 2,891 Sep-30-2018, 03:29 AM
Last Post: nikos

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020