Is it possible to double redirect after single request

are there any ways to double redirect after single request in django? for example, I have a View, after post request I want to for the first time redirect to one page, and then automatically redirect to another page. Is it possible to implement it in django ?

I’m not understanding what you’re trying to achieve here.

Are you saying that the first time each user POSTs to that view, they go to “Page A”, but all subsequent times they go to “Page B”?
Or is it the first time anyone POSTs to that view they go to “Page A”, and everyone after that goes to “Page B”?

In either case, you’re going to need to track that in your database somewhere. But yes, it can be done.

second option is relatable for me, and if it is possible, can you please share any sources or hints to implement that?

For each user, track whether or not they’ve posted to that page. (You could have a Model for that page with an FK to User and a “tracking flag”, or you could add a tracking flag to the User’s profile model if you’re using one of those. The choices depend upon whether this is the only page you want to do this for or if this is going to be a regular pattern throughout your app.

The precise mechanic for this is going to depend upon your view and how you’re handling the POST.

1 Like