On Tue, Nov 7, 2017 at 6:28 AM C. Kirby <[email protected]> wrote:

> You have two choices. One would be to use the relatively new Channels
> feature, which allows you to keep a communication stream open so that you
> would have the processing page show until the sever notified the client
> that it was done and sent the data. I've not worked with Channels much, so
> if you have questions about that you can follow up to this list.
>
> The other option is to have a model that stores the result of the
> calculation. Example
>
> class CalcResult(models.Model):
>     result = models.IntegerField(blank=True, null=True)
>
> When the user submits the parameters you would create a new instance of
> this class:
>
> current_calc = CalcResult.objects.create()
>
> Now that you have that object you can pass the pk back to your processing
> view. Inside the processing view you can use javascript to poll the server
> with a view that checks if the pk has a result yet. when it gets a result
> you load the page that shows the result.
>
> Be aware that you cannot do this in the standard request/response cycle.
> When you send a response the interaction is done. In order to have your
> long running calculation work while the client is interacting with the
> system via a processing page you will need to use something like Celery or
> django-rq to offload the long running calculation.
>
> Hope this helps,
> Kirby
>
> On Monday, November 6, 2017 at 2:46:41 PM UTC-5, Ruifeng Hu wrote:
>>
>> Hi All,
>>
>> I am writing a project, on the submit page, a user submits some
>> parameters, then the server side will take a calculation that may take a
>> while, I want to add a waiting page to tall users that it is running on the
>> server. When the result is ready, it will automatically jump to the result
>> page.
>> I do not know what I should do to get these!
>>
>> Is there anyone can help me!
>>
>> Thank You!
>>
>> Best,
>> Ruifeng Hu
>>
> It seems to me that the easiest way to do this is via an Ajax call in
JavaScript.  In my experience channels is very hard to set up.
-- 
-- 

Adam F. Simon, PhD
Calabasas, CA.

cell:      818-425-3719
home:   818-880-8405

Feel free to link w/ me: LinkedIn

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAH-jdcwmGAzDa_1uSAHySxMEpMwf%2BpfGczKtNL6Y0iZFDpMOMg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to