Sunday, October 30, 2011

Re: django request.POST data caching

I apologize if this answer doesn't help much -- I'm confused by your question.

request.POST doesn't cache anything. It's simply filled with data submitted by the browser on that specific request.

If you click "Back" on your browser, many times the browsers will simply re-fill those form fields in with what you had typed in before. This is nothing specific to Django. 

I'm not aware of any HTML methods to inhibit this behavior. Keep in mind that it is good practise to have a redirect after every POST. For example, when the user submits the form, process that form, then redirect them to display whatever you want them to see, even if it is just additional form fields (within the same, or another, view).

I'm not sure what you're trying to achieve by clicking on the "back" button -- but if you give some more information on what you're actually trying to achieve, I'd be happy to try give you some better help.

Good luck!

On Sat, Oct 29, 2011 at 10:06 AM, luke lukes <lordluke80@gmail.com> wrote:
hi have a template with a form and many inputs that pass some data
trough a POST request to a view, that process them and send the result
to another template. in the final template, if i use the browser back
button to jump to the first view, i can see again old data. i refresh
the page and i insert new data, i submit again but some old data
remain when i see the final view. the problem remain even if i restart
the debug server. it seems that there's some data-caching that i can
solve (and somethimes not) only flushing browser cache. this is the
view code: http://dpaste.com/640956/ and the first template code:
http://dpaste.com/640960/. someone on stackoverflow.com that is cache
navigator and suggest me to use a custom middleware to disable it:
http://stackoverflow.com/questions/7921457/django-post-request-data-caching,
so i followed the advice. i also added the pragma no cache meta tag in
the html head section, but none of these helped. the problem remains.
any suggestion?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment