Python Forum
redirect url_for passing arguments with the url
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
redirect url_for passing arguments with the url
#1
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!
Reply
#2
Solved:
    takeid = str(dict1["_id"])

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


Possibly Related Threads…
Thread Author Replies Views Last Post
  Problems passing arguments containing spaces to bash script and then on to python kaustin 6 347 Apr-03-2024, 08:26 PM
Last Post: deanhystad
  Passing writable arguments to functions. Assembler 11 923 Jan-15-2024, 11:32 PM
Last Post: sgrey
  redirect STDIO in the Python code Skaperen 6 1,289 Jul-05-2023, 12:23 AM
Last Post: Skaperen
  Passing string functions as arguments Clunk_Head 3 1,244 Jun-15-2022, 06:00 AM
Last Post: Gribouillis
  stderr redirect to file fmr300 2 3,570 Apr-03-2021, 01:31 AM
Last Post: fmr300
  Cannot redirect print to a file tester_V 3 2,502 Sep-11-2020, 12:21 AM
Last Post: tester_V
  passing-arguments-from-one-script-to-another jacklee26 7 3,249 Apr-21-2020, 03:55 PM
Last Post: deanhystad
  Redirect to __stdout__ fails in IDLE shell Pavel_47 1 1,957 Apr-13-2020, 05:13 PM
Last Post: deanhystad
  Redirect to file vndywarhol 1 2,298 Aug-23-2018, 11:01 AM
Last Post: DeaD_EyE
  Python redirect users to another url after form post blsturgeon 5 18,830 Jun-28-2018, 11:53 PM
Last Post: gontajones

Forum Jump:

User Panel Messages

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