-1

Error : Could not build url for endpoint 'my_lynk_page' with values ['fk_page_id']

Below is the redirect where I get the error

@app.route("/pages/add", methods=["POST"])
def proc_pages_add():
    params               = request.form.to_dict()
    response             = pages_proc.pages_proc(app)._add_page( params )

    redirect_to = response["message_data"]["redirect_to"]
    fk_page_id  = response["message_data"]["fk_page_id" ]

    return redirect( url_for(redirect_to, fk_page_id = fk_page_id ))

Below is where it should return to

@app.route('/admin/my-lynks/<fk_page_id>', defaults={'fk_page_id': 'home'})
def my_lynk_page(fk_page_id):
    params               = request.args.to_dict()
    params["fk_user_id"] = session.get("fk_user_id"         )
    params["fk_page_id"] = fk_page_id
    session["fk_page_id"] = fk_page_id
    
    html                 = view_my_lynks.view_my_lynks(app).html( params )
    html_resp            = make_response( html )
    html_resp.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
    return html_resp
# end def

Is there naming standards I'm not aware?

  • Could you share the full error message or also maybe the value of `redirect_to`? – Patrick Yoder May 10 '22 at 16:12
  • 1
    I think the problem is the default. I removed the default. But its quite confusing. As far as I know, default works if the fk_page_id is not included when its called it will automatically set the fk_page_id as home. – Glenn Karl Guiyab May 15 '22 at 09:55
  • 1
    Hmm, ok. I think you need two `@app.route` lines for this to work. See [here](https://stackoverflow.com/q/14032066/15368978) for more details and suggestions. – Patrick Yoder May 15 '22 at 22:19

0 Answers0