How to use async in Django
滿天的星座
滿天的星座 2017-06-12 09:27:03
0
1
680

There is a return render in views that requires a long wait for the database, so I would like to ask how to implement it and display the templates first. Then wait for the data to be added. I have seen such an article before, but now I want to find it, but I can’t find it. Maybe the expression is wrong.

If the above may not be done asynchronously like this, then the following situation:
There is a page, and when the page is loaded, there will be a front-end to request data asynchronously. This data has nothing to do with the data on this page, but It is necessary to dynamically display the data on this page. The closer one is the top statistics. For example, if it is top statistics, then my views before loading this page will asynchronously output the top results and wait for the front-end to load asynchronously. How to achieve this. I hope to post some simple asynchronous code in views. (Asynchronous novice) Both questions are about loading templates now.

python 2.7
Thank you

滿天的星座
滿天的星座

reply all(1)
小葫芦

I think what you need is front-end ajax. For specific usage, you can go to Google. This is a commonly used method of asynchronously requesting data. When a user accesses, the template can temporarily return temporary data, or part of the data, when the page After loading, or when the scroll bar reaches the bottom of the page, trigger ajax to request new data, and then use js to redraw the corresponding page elements. Of course, you can also use some excellent front-end frameworks, such as vue.js or agular.js , these are solutions specifically designed to solve your needs

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template