开发者

Pass variables to a "success" page after processing a form in Django

Is there anyway to pass context variables to a redirect response? I want to redirect a user to a success page after they submit a form, but I don't want the success page to be just a static html file. I need to display extra information based on the form data.

I have looked at this question, but the solution presented there simply renders a different file at the same url. I'd like to redirect the user so that hitting refresh at the page won't submit duplicate entries into the application.

Right now the only thing I have been able to use with some success is redirecting to a url while passing it GET variables as described here. That just seems like开发者_如何学JAVA a bit of a hack, and was just wondering if there is any better solution...

Thank You


The way I see it you have three options:

  1. Use GET variables in the redirect.
  2. Store something in the session.
  3. If you are creating an object using the form that was submitted, put the id of that object in the redirect url and use it in the new view.

The limitation you are running up against is that http is stateless, not something inherent in django.


How about storing your values in a session, then have the redirected page pick up the values from there?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜