0

I am submitting a form using Django. All things went well until I hit back button. This is the time IE displays "The wab page has expired. "

I have searched a lot, but can not find the exact concept to do it right.

  1. Open page with get request . /user/search/
  2. Post request with form data on the same page /user/search/
  3. [Optional] Either change params and POST
  4. Hit back button.

In both cases you will get webpage Expired. Please guide me how to make this work & avoid the error message?

A.J.
  • 6,664
  • 10
  • 55
  • 74
  • On completion of `POST` request on `/user/search/` , redirect using `HttpResponseRedirect` OR `redirect` instead of `reander_to_response` or `HttpResponse` . – Priyank Patel Mar 10 '14 at 09:37
  • Look, i have my search results in Context_var = {'results': Objects.all()} If i Redirect it, who would i be able to get this info? I will loose this information right? Correct me if i am wrong – A.J. Mar 10 '14 at 09:42
  • if you are trying to say somthing like this `template = loader.get_template('project_list.html')` `context = RequestContext(request, {'key', val})` `return HttpResponse(template.render(context))` I have tried it too. it didnt work. – A.J. Mar 10 '14 at 09:52

1 Answers1

2

You shouldn't be using POST for search forms. POST is for actions that change data on the server. Use GET and you won't have this problem.

Daniel Roseman
  • 541,889
  • 55
  • 754
  • 786
  • Daniel, Can you please quote or cross reference this? `POST is for actions that change data on the server` GET has no problem at all, i was just curious about the issue. – A.J. Mar 10 '14 at 10:30
  • Well, there are plenty of questions here at SO which talk about that: see for example [this](http://stackoverflow.com/questions/504947/when-should-i-use-get-or-post-method-whats-the-difference-between-them) and [this](http://stackoverflow.com/questions/3477333/what-is-the-difference-between-post-and-get). – Daniel Roseman Mar 10 '14 at 11:09
  • Thanks ,,, I needed a ref. +1 – A.J. Mar 10 '14 at 11:13