I feel like I'm doing something rediculously stupid here, but I've been banging my head against the wall all day, and don't seem to be making any progress! I have this function:
def init_create_reports(self, msg):
if not common.create_report_in_progress and len(common.tracks_selected_for_report) > 0:
common.create_report_in_progress = True
return jp.redirect('/yeeha')
That is called when the user clicks a button. Stepping through it, everything works fine until the redirect function, which seems to fire from within justPy, but then I get nothing. It never redirects to the '/yeeha' route. It seems simple enough according to the godawful justPy documentation, but agaghhhhh!
I've also tried passing the redirect the current webpage: wp.redirect('/yeeha') with the same outcome. Honestly all I need is to set that variable and navigate to another page, and at this point I'm prepared to just do it from a tag.
It seems that there is currently a problem in Justpy with the handling of the event_result of an event callback function. I opened an issue for this problem. See https://github.com/justpy-org/justpy/issues/657
Alternatively to
jp.redirect()
you can also set the redirect attribute of the webpage.In your example it would be:
Here is a complete example showing a redirect from one justpy webpage to another route:
See also Login Example