Wednesday, February 27, 2013

Re: Redirect and execute after 2 seconds?

Hi Maria,

as Bill explained, you should be looking at JavaScript for everything that happens on the client-side (i.e. after the page has left the server).

However you should consider shifting more of the logic to the client-side in this case. For time-based actions with such a short duration the additional overhead involved in sending and receiving a web page could affect the results quite dramatically, especially when the user is on a dodgy connection (think mobile or dial-up).

You may want to look into learning AJAX to communicate between the client and server without requiring a full page reload and into a front-end library like jQuery for adding the necessary client-side logic to hide and reveal elements on the page (i.e. client-side) or provide dynamic updates after the page has been sent by the server (Django).

There are some good live coding exercises and screencasts available online if you want to learn more about jQuery or other front-end libraries or just JavaScript in general.



On 27.02.2013 15:01, Maria wrote:
Hi everyone! :)
I am working on a project for my studies, it is a web poll where you can only answer yes or no by clicking on buttons.
If the user clicked on one button, the result will be saved in a text-file and the user will be redirected to another page with a random id:
return HttpResponseRedirect ('/polls/'+str(sid))
If the user doesnt click on any button quickly enough, I want the page to redirect them after 3 seconds to another page with a random id AND i want to save the id of the question that wasnt answered.  How can I do it? I searched the web but only found the time.sleep function. As far as I understood, I cant use the sleep function because the site has to do other stuff while the 3 seconds pass.
I would be very thankful for any help on this!
Kind regards,
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment