> I am using HttpResponseRedirect... it still seems to allow a
> duplicate post though if refresh is hit on the page it's been
> redirected to.

Is this happening when a user clicks the Submit button twice 
before the redirect comes in (thus Django processes two requests 
from the same originating page, rather than from the response-page)?

You can minimize double-submits via a little JavaScript code, 
disabling the submit button in the onclick before submitting. 
However, this doesn't 100% solve the problem, particularly if JS 
is disabled (whether by browser limitation, or by user choice, 
such as the wonderful NoScript plugin for FireFox which I use 
regularly)

To prevent this, you need to uniquely identify the page from 
which it was submitted (a hash of the IP address, timestamp the 
form was generated, user info, whatever) and then only allow that 
identifier to be processed once.  You'd have to keep a model of 
"recent posts".  If the hash is in there, the request you're 
currently trying to process has already been processed.  It would 
be good to have this table auto-purged after some reasonable amt 
of time, such as a couple days or a week.  Huzzah for cron-jobs :)

If you wanted to get fancy and your app had need of it, you could 
hash the submitted data from the form (including the initial 
unique identifier).  This would allow the user to click their 
Back button, return to the form, make changes and submit it a 2nd 
time.  This can be useful in a data-entry scenario where you want 
to ensure that the 2nd submission actually has new data, not the 
same data from accidentally double-clicking the submit button. 
It's nice to have the usage pattern of "fill out the form; submit 
the form; click the back button; change something; submit the 
form; click the back button; <ad infinutum>"

Just a few ideas,

-tim





--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to