Re: model sends two requests
On Mon, 9 Jul 2012 09:26:15 -0700 (PDT), jonas peters
<jonas.peters123@gmail.com> declaimed the following in
gmane.comp.python.django.user:
> I have a model and use standard django administration, when a user clicks
> the save button it sends the request, it takes time to respond and the user
> clicks the save button again and then sends another request, and creating
> two records. have some setting in django to avoid this problem? I thought
> about locking the save button when it is clicked so the user does not click
> more than once to complete the request.
>
In general (that is, not Django specific), my experience is that
potentially slow sites in which an extra submittal would cause problems
tend to include a warning message to only click once (the sites I've
seen this on tend to be online markets -- where the warning is that
double clicking could result in a second order charged to the credit
card.
The other general solution would be to collect the data, send it to
a separate worker thread/process and immediately return a "please wait"
type response -- this response should have an automatic redirect (using
a cookie to identify the worker) to a page that will either find the
worker thread has finished and can return the real next page -- or if
the worker is still busy resend the "please wait" page.
More specific modes:
http://www.turnkeylinux.org/blog/prevent-double-click-form-submission
(general search: prevent double click form submit
http://www.google.com/#hl=en&sclient=psy-ab&q=prevent+double+click+form+submit&oq=prevent+double+click+form+submit&gs_l=serp.3..0i30j0i5i30.8464.23704.0.23926.28.25.2.1.1.6.503.4601.0j21j3j5-1.25.0...0.0.c3W_7yOZRzI&pbx=1&bav=on.2,or.r_gc.r_pw.r_qf.,cf.osb&fp=9da4b66dc5fd8e9a&biw=1044&bih=748
)
> Sorry my english Thanks!
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
--
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.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home