Django - show loading message during long processing

前端 未结 7 1434
野的像风
野的像风 2020-12-03 03:54

How can I show a please wait loading message from a django view?

I have a Django view that takes significant time to perform calculations on a large dataset

7条回答
  •  旧巷少年郎
    2020-12-03 04:28

    Another thing you could do is add a javascript function that displays a loading image before it actually calls the Django View.

    function showLoaderOnClick(url) {
          showLoader();
          window.location=url;
      }
    function showLoader(){
          $('body').append('
    Loading...
    '); }

    And then in your template you can do:

    This will take some time...
    

    Here's a quick default loadingDiv : https://stackoverflow.com/a/41730965/13476073 Note that this requires jQuery.

提交回复
热议问题