Another question like this one was asked, but I don’t ‘like’ the answer (in reality it didn’t really answer the question in the first place): Can any one explain how can i pass arg or kwargs from redirect to another view?)
I have a view and need to redirect to another view (in another application) and still send an argument along. Currently I have:
return redirect('/projects/', login_error=error)
Which doesn’t work (the redirect happens but the argument doesn’t go through). Is it even possible to do this using redirect()? The documentation doesn’t have anything on it.
However, I also tried referring to the view without using a URL:
return redirect('projects.views.list_all', login_error=error)
But that doesn’t work either.
redirectreturns an HTTP redirect to the supplied URL – that is, the browser receives a30x response and initiates a new request.
To preserve state between the two requests, you either need to set a session variable (as per the other answer) or provide a query parameter, eg:
You will then need to process the incoming
request.GETparameter in the other view.