Preventing Multiple Submits

21 views
Skip to first unread message

Ian Maurer

unread,
Sep 28, 2006, 9:16:45 PM9/28/06
to django...@googlegroups.com
Just wondering if anyone has thought through the problem of multiple
submits due to multiple clicks of a submit button?

I am already properly using POSTs and GETs and doing a redirect after
a POST, as recommeded by the Django docs.

The issue I am talking about is when a user clicks the submit button rapidly.

The "easy" answer is to use JavaScript to disable the submit button
after the first click and I guess I am leaning towards that since I do
require JavaScript for the particular app I am working on. However, I
was hoping to come up with a more general purpose solution.

One thought I had was overriding the AddManipulator and adding a
hidden field with a "token". And then using the Session map to store
and retrieve the primary key of a created object using the token.

Then it occurred to me that the CSRF middleware is already doing
something very similar and I was wondering if anyone already leveraged
it to also handle this problem? (Or can think of a reason why not to)

http://www.djangoproject.com/documentation/csrf/

And even if I do solve this problem, there are still synchronization
issues to deal with the multiple submits. (ie, if request 1 doesn't
store the pk prior to request 2 goes looking for it).

I am beginning to think that I am overthinking this, but I still want
to see if anyone else has thought this through...

thanks,
Ian

Reply all
Reply to author
Forward
0 new messages