Skip to main content

Redirect

Use the redirect(url, params) function redirect a user to another URL either external or internal.

Basic example

from abstra.forms import redirect

def open_abstra_cloud():
redirect("https://abstra.io")

Using query params

You can also pass query params to the redirect function:

from abstra.forms import redirect

def open_user_page(user_id):
redirect("https://home.abstra.app/user", {"user_id": 123})
# Redirects to https://home.abstra.app/user?user=123

If you don't pass query params to the redirect function, it'll keep the current query params:

# current url: https://home.abstra.app/first_form?user=456

def open_user_page():
redirect("https://home.abstra.app/user")
# Redirects to https://home.abstra.app/user?user=456

If you want to remove any query params from the current url, use {} in the query params arg:

# current url: https://home.abstra.app/first_form?user=456

def open_user_page():
redirect("https://home.abstra.app/user", {})
# Redirects to https://home.abstra.app/user