Python Forum

Full Version: redirect url_for passing arguments with the url
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello Coders!

I have a problem with a redirect, I'm a very beginner, and I would like to accomplish to this!

I show you the code:

# This is the Object ID 
myMongoDB_id = str(dict1["_id"])

return redirect(url_for('recipe/', myMongoDB_id))
As you can see I have myMongoDB_id that actually takes the Object ID from my MongoDB record.

In this way as soon as I submit the recipe through a form, the user gets redirected to /recipe/5f034b69b91c57308938cf82 and can directly see the recipe posted, but my redirect doesn't work. Please could you tell me why? I tried many things but I can't manage to pass the Object Id.

Thank you very much!
Solved:
    takeid = str(dict1["_id"])

    return redirect(url_for('recipe', recipe_id=takeid))